1 | function onTouched(hit) |
2 | script.Parent.Ghost:play() |
3 | end |
4 | script.Parent.Touched:connect(onTouched) |
Whenever someone will touch this, it will play the sound or will play 'Ghost'
But the problem is, the song will repeat and repeat if someone keeps jumping and stepping on the brick.
So can you guys help me with this?
1 | function onTouched(hit) |
2 | local ghost = script.Parent.Ghost |
3 | if ghost.isPlaying = = false then |
4 | script.Parent.Ghost:play() |
5 | end |
6 | end |
7 |
8 | script.Parent.Touched:connect(onTouched) |
The isplaying property lets you check if the sound is playing or not.
You can check if the song isPlaying == false
and if it is, let it activate, but if it is playing, don't let it activate:
1 | function onTouched(hit) |
2 | if script.Parent.Ghost.IsPlaying = = false then |
3 | script.Parent.Ghost:play() |
4 | end |
5 | end |
6 | script.Parent.Touched:connect(onTouched) |
Is it possible to add
1 | wait( 3 ) |
or something like that?
I really wanna make a scary horror game.