Inside of a localscript, I have
event = game.ReplicatedStorage.OpenDoors DoorVal = script.Parent.DoorValue event.OnClientEvent:connect(function(...) local tuple = {...} if tuple[1] == "Door" then print(tuple[2]) DoorVal.Value = tuple[2] script.Parent.Label.Visible = true elseif tuple[1] == "DoorStop" then DoorVal.Value = 0 script.Parent.Label.Visible = false end end)
It does print it, but it doesn't change it at all - why?
First of all -- tab your code.
Second. There's no reason to use tuple
when you know the number of arguments that you need is going to be 2. Just specify your two arguments:
event.OnClientEvent:connect(function( command, value) if command == "Door" then print( value ) DoorVal.Value = value script.Parent.Label.Visible = true elseif command == "DoorStop" then DoorVal.Value = 0 script.Parent.Label.Visible = false end end)
As far as I can determine, this should change DoorVal
. Remember that if FilteringEnabled is on, the server won't see the change.
Also remember that DoorValue is in script.Parent
, so check that you're looking in the right place.
Also, an aside. Even if you were to use your tuple = {...}
you could effectively assign variable names like this:
command, value = unpack(tuple)
Or better yet
command, value = ...