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

I made a toggle script and I don't know the parameter given by the event so it's giving an error?

Asked by 4 years ago

I'm making a door that allows only the owner. The players can go through, if the owner toggles that they can go. The script below is the toggle script. I'm suspecting that the parameter is wrong. So the question is, what parameter does the event MouseButtonClick provide in the function?

print("Hello world!")
local TrueColor= game.Workspace.Model.Values.ValidColor
local Allow= game.Workspace.Model.Values.IsTheDoorUnlocked
local FalseColor= game.Workspace.Model.Values.InvalidColor
local toggle= script.Parent

toggle.ClickDetector.MouseClick:Connect(function(whoClicked)
    local player= game.Players:GetPlayerFromCharacter(whoClicked)
    if player.UserId== 263105732 then
        Allow.Value= not Allow.Value
        if Allow.Value== false then
            toggle.BrickColor= FalseColor.Value
        else
            toggle.BrickColor= TrueColor.Value
        end
    end
end)
1
The MouseClick event's parameter provides the player that clicked the ClickDetector Sorukan 240 — 4y

1 answer

Log in to vote
1
Answered by
Sorukan 240 Moderation Voter
4 years ago
Edited 4 years ago
print("Hello world!")
local TrueColor= game.Workspace.Model.Values.ValidColor
local Allow= game.Workspace.Model.Values.IsTheDoorUnlocked
local FalseColor= game.Workspace.Model.Values.InvalidColor
local toggle= script.Parent

toggle.ClickDetector.MouseClick:Connect(function(player)
    if player.UserId == 263105732 then
        Allow.Value = not Allow.Value
        if Allow.Value== false then
            toggle.BrickColor= FalseColor.Value
        else
            toggle.BrickColor= TrueColor.Value
        end
    end
end)

The parameter IS the player who clicked it so there's no reason to use GetPlayerFromCharacter. I haven't tested this yet but it should work

1
theres a space in "toggle.BrickColo r= TrueColor.Value" RAFA1608 543 — 4y
Ad

Answer this question