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)
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