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

How do I end a song after I played it once?

I added a part in workspace, then a surface gui, then a textbox in the surface gui. I put in the textbox "Touch me to play music"

I added a script in the part (not in the surface gui, or the textbox). This is the script I added. I named the part "MusicPlayer"

So what I am basically trying to do here is to play a song ONCE and then it ends after. Here is the script:

`` if game.Workspace.MusicStarter.Touched.connect(musiccircuit)then function musiccircuit() Instance.new("Sound", game.Workspace.MusicStarter)--Added a sound in the MusicStarter part local music = game.Workspace.MusicStarter.SoundId("rbxassetid://238976867") music.Play("rbxassetid://238976867") wait(120) --The length of time to play the music before it ends. end end

2 comments

2

Is the property Looped set to false? If unchecked it should only play once when the function Play is called.

0

Also, use mustic:Play() and music:Stop(). It would make it more easy for you (:

2 answers

`` if game.Workspace.MusicStarter.Touched.connect(musiccircuit)then function musiccircuit() Instance.new("Sound", game.Workspace.MusicStarter)--Added a sound in the MusicStarter part local music = game.Workspace.MusicStarter.SoundId("rbxassetid://238976867") music.Play("rbxassetid://238976867") wait(120) --The length of time to play the music before it ends. 
music:Stop()

1 comment

0

oh and plz use a code block

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