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

Why won't tuple[2] change an IntValue?

Asked by 10 years ago

So, I have a series of scripts using a remove event, and the only part of the event that doesn't work is changing the value of an IntValue.

The first script, which fires when you touch a part:

local event = game.ReplicatedStorage.OpenDoors

local DoorVal = 1

script.Parent.Touched:connect(function(hit)
if (hit.Parent) and (hit.Parent:FindFirstChild('Humanoid')) then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if (Player) then
event:FireClient(Player, "Door", DoorVal)
end
end
end)

It's basically sending a "Door" and a number to the client.

So then, it gets to here,

event = game.ReplicatedStorage.OpenDoors

event.OnClientEvent:connect(function(...)
    local tuple = {...}
    if tuple[1] == "Door" then
        script.Parent.DoorValue.Value = tuple[2]
        script.Parent.Label.Visible = true
    else
        if tuple[1] == "DoorStop" then
            script.Parent.DoorValue.Value = 0
            script.Parent.Label.Visible = false
        end
    end
end)

It does not register the tuple[2] as the DoorValue in the IntValue, and I know this is the error, because when I manually set it to 1 and test it in game, it works like a charm. Why isn't it registering tuple[2] as an IntValue?

0
Your error may be that ROBLOX arrays start at arrayname[1] not arrayname[0] Sublimus 992 — 10y
0
What? LennyTheLucario 45 — 10y
0
I'm not sure why is isn't working, but couldn't you just just set script.Parent.DoorValue.Value on line 6 to 1 in this case? Or is the second tuple argument required for some part of the script not shown? BlackJPI 2658 — 10y
0
It's supposed to send a value in tuple[2] to show which door to open on a KeyPress of e, but I didn't show that part because it's the value not changing, and not the KeyPress event. LennyTheLucario 45 — 10y

Answer this question