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

Button isn't working once clicked. Suppose to stop all sounds. Why?

Asked by
ghxstlvty 133
4 years ago
Edited 4 years ago
workspace.CodeRedButton.ClickDetector.MouseClick:Connect(function()
    script.Parent.ClickDetector:Destroy()
    script.Parent.SurfaceGui.TextLabel.Text = "Please Wait"
    wait(5)
    Instance.new("ClickDetector", script.Parent)
    script.Parent.SurfaceGui.TextLabel.Text = "Disable Code Red"
end)

script.Parent.ClickDetector.MouseClick:Connect(function()
    for i,v in pairs(workspace.Lights.Lights:GetChildren()) do
        if v:IsA("Part") then
            v.BrickColor = BrickColor.new("White")
        end
    end
    workspace.Breach:Stop()
    wait(3)
end)

2nd function doesn't work. No error codes.

0
What's not working correctly? Are you trying to find and stop playing all the sounds inside the part? AlmostADemon 50 — 4y
0
Is this in a local script? deadwalker601 110 — 4y
0
Have you tried replacing .Sound3 with ["Sound3"] or :FindFirstChild("Sound3")? misha123 83 — 4y
0
This is a server script. ghxstlvty 133 — 4y
View all comments (2 more)
0
I made edits to the script. ghxstlvty 133 — 4y
0
Don't use :Stop() CandyWreckEpicness 115 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

It is not a good practice to destory the clickDetector, as when you create the new one you would need to reassign the events. Instead use a property on the clickDetector called "MaxActivationDistance" and set it to zero to disable the button.

workspace.CodeRedButton.ClickDetector.MouseClick:Connect(function()
    script.Parent.ClickDetector.MaxActivationDistance = 0
    script.Parent.SurfaceGui.TextLabel.Text = "Please Wait"
    wait(5)
    script.Parent.ClickDetector.MaxActivationDistance= 32
    script.Parent.SurfaceGui.TextLabel.Text = "Disable Code Red"
end)
Ad

Answer this question