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

Why wont this play the sound on click? [ANSWERED]

Asked by 8 years ago

Hi I was scripting this script were you click this model it plays a sound a deletes the model. Can you please help?

function OnClick(theguythatclicked)
    local clicks = theguythatclicked:FindFirstChild("leaderstats"):FindFirstChild("Cow Clicks")

    if clicks then
        clicks.Value = clicks.Value + 1
        script.Parent.Sound:Play()
        script.Parent:Destroy()
    end
end

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

3
You're destroying the place the Sound is kept in before it has a chance to start playing. You start the sound on line 6, but you basically delete it on line 7 with the destruction of the script's parent. M39a9am3R 3210 — 8y
0
Okay thanks! docrobloxman52 407 — 8y

Answer this question