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

The player can't click the button?

Asked by 2 years ago

I was making a single player and i want it so that if the player clicked the button, they didn't die. But if the player didn't click the button after 8 seconds, they die.

The only problem is that the button is not working even if i think it was correct. I'm new to scripting. The code was in a normal script with the button as it's parent. Thanks for reading!

Code :

correctVar = false

wait(10) script.Parent.Visible = true wait(8) if correctVar == false then script.Parent.Parent.Parent.Parent..Character.Humanoid.Health = 0 script.Parent.Visible = false end

script.Parent.MouseButton1Down:Connect(function() correctVar = true script.Parent.Visible = false print("The player clicked the button!") end)

The player can't click the button, but they die after 8 seconds.

1 answer

Log in to vote
0
Answered by
Jac_00b 157
2 years ago

It's because when you do the click function, you don't link it to the click detector. The type of click function you used is for GUIs. Instead of

script.Parent.MouseButton1Down:Connect(function()

You should do

script.Parent.ClickDetector.MouseClick:Connect(function()
Ad

Answer this question