Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't my IntValue change?

Asked by 10 years ago

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?

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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 = ...
0
I usually do tab my code, but in a hurry, I C&Ped of the ROBLOX forums that I've been waiting forever for an answer. It still prints, but the value doesn't change. LennyTheLucario 45 — 10y
0
Try printing `DoorVal:GetFullName()` and be sure you're looking in the right place? Another thing to check would be that `"DoorStop"` isn't being immediately sent after it (add a print there, too) BlueTaslem 18071 — 10y
0
The DoorStop event can't interfere with it because it also does not work. LennyTheLucario 45 — 10y
Ad

Answer this question