I'm trying to write a script that will play the first four seconds of a sound over and over when a button is clicked, then stop when another button is clicked. It works when I test in studio, but when I go to play my game, it plays the full sound and doesn't repeat. Here's the script I'm using:
v = 1 clicker = script.Parent.ClickDetector function onClicked(mouse) while v == 1 do game.Workspace.alarm:Play() wait(4) game.Workspace.alarm:Stop() end end
function Click(mouse)
v = 2 wait(4) v = 1
end
game.Workspace.override.ClickDetector.MouseClick:connect(Click) script.Parent.ClickDetector.MouseClick:connect(onClicked)
What am I doing wrong?