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

Script works during testing, but not during play. What am I doing wrong?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm trying to write a script that will play the first four seconds of a sound over and over after a button is clicked, then stop when another button is clicked. The script works perfectly when I'm testing the place, but whenever I go play it, the entire sound plays and it doesn't repeat. Here's the script I'm using:

v = 1
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)
0
Did you set the "alarm" sound's property Looped to true? That makes it loop until you want to stop. Marios2 360 — 9y

Answer this question