So I am making a script that will make a text pop up if you click on a brick. It doesn't work though, and there are no errors that popped up.
script.Parent.ClickDetector.MouseClick:Connect(function(onClick) end) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true wait (5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false
You didn't write the code inside of the function
script.Parent.ClickDetector.MouseClick:Connect(function(onClick) --This is where you should put the function's code end) --This is the end of the function --This is outside of the function so it won't fire when the function is called upon game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true wait (5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false
So if you just placed your code inside the function like this
script.Parent.ClickDetector.MouseClick:Connect(function(onClick) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true wait(5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false end)
Everything should work as intended
Try this script:
local Part = script.Parent script.Parent.ClickDetector.MouseClick:Connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local Player = game.Players:GetPlayerFromCharacter(HIT.Parent) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true wait (5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false end end)