function onTouched(hit) script.Parent.Ghost:play() end 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?
function onTouched(hit) local ghost = script.Parent.Ghost if ghost.isPlaying == false then script.Parent.Ghost:play() end end 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:
function onTouched(hit) if script.Parent.Ghost.IsPlaying == false then script.Parent.Ghost:play() end end script.Parent.Touched:connect(onTouched)
Is it possible to add
wait(3)
or something like that?
I really wanna make a scary horror game.