Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui plays sound instantly ?

So basically this script is about a player touching a part then playing a 15 second song. But what happens is that it plays instantly when I test my game. How do I fix it so it doesn't play instantly?

Song = script.Parent.sound

function PlaySong()
	Song:Play()
	wait(15)
	Song:Stop()
end

game.workspace.soundplayer.Touched:connect(PlaySong)

It's in script is a local script under the startergui and sound is also inside aswell

Edit: I think it may just be a bug. I just tested it again but not in test mode. Doesn't play weird.

2 answers

✓ Accepted answer

Put the script in the part.

Song = script.Parent.sound -- Fix if its incorrect

function PlaySong()
    Song:Play()
    wait(15)
    Song:Stop()
end

script.Parent.Touched:connect(PlaySong)

Ok so basically at the start of the script say wait (Time)

This discussion is preserved as it was. New answers, comments, and votes are closed.