Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my IntValue change?

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

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 = ...

3 comments

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.

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)

0

The DoorStop event can't interfere with it because it also does not work.

This discussion is preserved as it was. New answers, comments, and votes are closed.