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

What is wrong with this script?

Asked by 8 years ago

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
v = 1


game.Workspace.override.ClickDetector.MouseClick:connect(Click) script.Parent.ClickDetector.MouseClick:connect(onClicked)

What am I doing wrong?

Answer this question