This is really confusing as I only need it to play Once, but whenever I collide, it replays the sound.
Here's What I have so far:
01 | local Sound = script.Parent.Sound |
02 | local Set = false |
03 |
04 | function onTouched(hit) |
05 | if Set = = false then |
06 | Sound:Play() |
07 | elseif Set = = true then |
08 | Sound:Stop() |
09 | wait( 3 ) |
10 | Sound:Stop() |
11 | Set = true |
Help is Greatly appreciated.
This assumes you have a part in workspace with this script inside it:
01 | local Sound = script.Parent.Sound |
02 | local Set = false |
03 |
04 | script.Parent.Touched:Connect( function (part) |
05 | if not Set then |
06 | Set = true |
07 | Sound:Play() |
08 | wait( 3 ) |
09 | Sound:Stop() |
10 | Set = false |
11 | else |
12 | Sound:Stop() |
13 | Set = false |
14 | end |
15 | end ) |