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

What is wrong with this Sound script?

Asked by 10 years ago
function OnClick(clicked)
    while true do
    script.Parent.Parent.Sound1:Play()
    wait(120)
    script.Parent.Parent.Sound1:Stop()
    wait(.1)
    script.Parent.Parent.Sound2:Play()
    wait(120)
    script.Parent.Parent.Sound2:Stop()
    wait(.1)
    script.Parent.Parent.Sound3:Play()
    wait(120)
    script.Parent.Parent.Sound3:Stop()
    wait(.1)
    script.Parent.Parent.Sound4:Play()
    wait(120)
    script.Parent.Parent.Sound4:Stop()
    wait(.1)
    script.Parent.Parent.Sound5:Play()
    wait(120)
    script.Parent.Parent.Sound5:Stop()
    wait(.1)    
    end
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)

What's wrong?

0
Is it supposed to be 0nClick instead of onClicked or is that just a typo? jav2612 180 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago

Seems like you used a script Template and got confused. when using :connect() you put inside your function. You called for the OnClicked where the was none. Also the "clicked" inside the functions parentheses has no meaning.

function OnClick()
    while true do
        script.Parent.Parent.Sound1:Play()
        wait(120)
        script.Parent.Parent.Sound1:Stop()
        wait(.1)
        script.Parent.Parent.Sound2:Play()
        wait(120)
        script.Parent.Parent.Sound2:Stop()
        wait(.1)
        script.Parent.Parent.Sound3:Play()
        wait(120)
        script.Parent.Parent.Sound3:Stop()
        wait(.1)
        script.Parent.Parent.Sound4:Play()
        wait(120)
        script.Parent.Parent.Sound4:Stop()
        wait(.1)
        script.Parent.Parent.Sound5:Play()
        wait(120)
        script.Parent.Parent.Sound5:Stop()
        wait(.1)
    end
end


script.Parent.ClickDetector.MouseClick:connect(onClick)


0
Thank you! kieranm9090 49 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

In the last line, after :connect you put the function you want to run in the parentheses. You want to Connect a MouseClick on a ClickDetector to the function in the parentheses. Get it?

Answer this question