Jump to content

Changing skin +1


Xeno

Recommended Posts

I made a GUI and created a button on it called "->" and I made it so that when you press it, it changes you skin by 1, and I dont know why, but it doesnt work? Here is my script!

addEventHandler ( "onClientGUIClick", right, goRight, false ) 

  
  
function goRight(player) 
        local currentSkin = getElementModel (player) 
setElementModel (player, currentSkin +1) 
end 
  

Link to comment

i bet you'll have to check if the next skin ID is valid, for example:

function goRight(player) 
  local newSkin = getElementModel (localPlayer) + 1 
  while not setElementModel (localPlayer,newSkin) and newSkin < 288 do  
    newSkin = newSkin + 1  
  end 
end 

PS: you'll also have to check if new skin ID is not more than 288, cause it'll stuck in infinite loop otherwise (there are no valid skins after 288)

Link to comment
Are you running this code server sided or clientsided?

Client, and debug shows nothing

as Aibo said, you have to check if the next skin is valid, if not keep continuing until you find a valid one.

also: try using this code serverside, changing skins and models is always best to do serversided, as clientside does not sync it for everyone, unless you want only the client to see the changes ( e.g. skin selection menu ).

Link to comment

Its something wrong with the addEventHandler, it says that it expect a gui-element at argument 1.... But "right" is gui...

edit: read the wrong debug, lol, it says it neds a function at argument 3, but as I said before, argument 3 has a function in it...

Link to comment

probably you call addEventHandler BEFORE you create the function itself.

you should define function first.

functions are the same as any variables — you can't use it until you define it.

you can't and don't do stuff like:

a = b + 1 
b = 10 

same with functions.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...