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

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

Asked by 8 years ago

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
Is the property `Looped` set to false? If unchecked it should only play once when the function `Play` is called. BlackJPI 2658 — 8y
0
Also, use mustic:Play() and music:Stop(). It would make it more easy for you (: User#11440 120 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago
`` 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()
0
oh and plz use a code block USArmyRanger2003 0 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Try making the music non loopable.

Answer this question