I made a script in which I press a button and then it makes a noise, and then another noise. Here's my script:
local Switched = script.Parent.Switched
function onClicked()
if Switched == false then
Switched = true
script.Parent.On:Play()
wait(0.5)
script.Parent.Off:Play()
wait(0.2)
Switched = false
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments
You're retrieving the object, then checking if it's "false". e-e
How would I fix it then?
You would use the WaitForChild function to yield the code until it exists, but are you trying to check if the GUI is visible? Your question is very vague on information.
Its fine, i fixed it myself by making the ClickDetector MaxActivationDistance 0 until it's done the clicking noise.