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 comment
The MouseClick event's parameter provides the player that clicked the ClickDetector