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

Restart a sound/song when player dies?

Asked by 5 years ago

So I have a script that works for the most part. It's in starterplayerscripts and basically when you join the game it plays a song, waits until the song is over(by seconds cause I dont know how to tell when it ends) then it plays the next and so on.

But the problem is if the player dies, it stops. No songs play at any point anymore unless you rejoin the game.

Here is the script:

local player = script.Parent.Parent
local gui = player:WaitForChild("PlayerGui")
local music = gui:WaitForChild("Music")

while true do
    wait()
    music.SongO:Play()
    wait(96)
    music.SongT:Play()
    wait(92)
    music.SongTH:Play()
    wait(88)
end

There are no errors or anything, music simply just doesnt play anymore if you were to die or reset and I was wondering whats causing that and how i'd go about fixing it?

1
humanoid.Died:Connect(function() song:Play() greatneil80 2647 — 5y
1
^you need to "end)" the function. abnotaddable 920 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

What you can do is just insert a local script to starter character scripts.

That will make it that every time you respawn, the local script will run again.

So all you have to do is play the sound in that local script. I won't post the script because from your post I guess you know how to play the sound.

If you have any questions or problems you can ask but if you set it up right it will surely work

Ad
Log in to vote
1
Answered by 5 years ago

The problem is, that you never told that It has to play when the player dies, add this.

game.Players.LocalPlayer.Character.Humaniod.Died:connect(function()song:play

If doesn't works don't hesitate to tell me

Answer this question