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

Gui plays sound instantly ?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
Ad
Log in to vote
0
Answered by 9 years ago

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

Answer this question