Xeno Posted November 25, 2011 Share Posted November 25, 2011 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
AeroXbird Posted November 25, 2011 Share Posted November 25, 2011 Try this: function goRight(player) local currentSkin = getElementModel (getLocalPlayer()) setElementModel (getLocalPlayer(), currentSkin +1) end Link to comment
Xeno Posted November 25, 2011 Author Share Posted November 25, 2011 Try this: function goRight(player) local currentSkin = getElementModel (getLocalPlayer()) setElementModel (getLocalPlayer(), currentSkin +1) end That doesnt work Thanks for replying though ;3 Link to comment
AeroXbird Posted November 25, 2011 Share Posted November 25, 2011 Are you running this code server sided or clientsided? Link to comment
^Dev-PoinT^ Posted November 25, 2011 Share Posted November 25, 2011 what the /debugscript 3 show? Link to comment
Xeno Posted November 25, 2011 Author Share Posted November 25, 2011 Are you running this code server sided or clientsided? Client, and debug shows nothing Link to comment
Aibo Posted November 25, 2011 Share Posted November 25, 2011 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
AeroXbird Posted November 25, 2011 Share Posted November 25, 2011 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
Xeno Posted November 25, 2011 Author Share Posted November 25, 2011 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
Aibo Posted November 25, 2011 Share Posted November 25, 2011 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
Castillo Posted November 25, 2011 Share Posted November 25, 2011 Maybe is adding the event handler too soon? Link to comment
Xeno Posted November 25, 2011 Author Share Posted November 25, 2011 You were both right, I had it too soon. I feel very dumb, i seem to get stuck on the little easy errors -.- Thank you all who helped me Link to comment
Castillo Posted November 25, 2011 Share Posted November 25, 2011 We all fail at something when learning, but that's how some people learn to fix their errors. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now