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

Play Specific Sound Once When Touched?

Asked by 8 years ago

Hey, I have this super simple script, but it really feels like a hard thing to do. When I touch a brick, it makes a sound, but it keeps playing over and over. Is there a way for it to just play once and then stop? Thanks!

1function onTouched(hit)
2    script.Parent.Sound:play()
3    wait(2)
4    script.Parent.Sound:stop()
5end
6 
7script.Parent.Touched:connect(onTouched)

-LukeGabrieI

1 answer

Log in to vote
1
Answered by 8 years ago

You need to make

1:play()

capitalized, like this:

1:Play()

same with

1:stop()

should be

1:Stop()
0
Anything else I should fix? LukeGabrieI 73 — 8y
1
Not really, but touched isn't recommended, I would use magnitude. DaCrazyDev 444 — 8y
1
how would you use magnitude? Coolboyok11 64 — 8y
Ad

Answer this question