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

Music restarting everytime the player dies, how to fix it?

Asked by 4 years ago
Edited 4 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

-- Variables local main = script.Parent:WaitForChild("Main") local sound = script.Parent:WaitForChild("Sound") local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY) local progress = main:FindFirstChild("ProgressBar").Progress local songName = main:FindFirstChild("SongName") -- Main Script while wait() do -- Repeats itself continuously sound:Stop() -- Stops the music progress.Size = UDim2.new(0,0,1,0) -- Resets the song's progressbar if not sound.IsPlaying then -- If the song has stopped local songChosen = songs[math.random(1,#songs)] -- Chooses a random sound local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the sound's info sound.SoundId = "rbxassetid://".. songChosen sound:Play() songName.Text = asset.Name -- Changes to text to the sound's name wait(1) -- Prevents errors progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1) -- Moves progress bar wait((sound.TimeLength)-1) -- Waits sound's time -1 end end
0
Can anyone edit my script ? crookmega312 -3 — 4y
2
Where is your music parented to? y3_th 176 — 4y
0
Starter Gui > MusicGui (ScreenGui) > MasterScript (LocalScript) crookmega312 -3 — 4y
0
Put it in StarterCharacter eyad27 8 — 4y
0
it's not working crookmega312 -3 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try This: if doesn't work put in sever script service, I think the reason is you didn't put the player added function.

game.Players.PlayerAdded:Connect(function(plr)
    -- Variables
local main = script.Parent:WaitForChild("Main")
local sound = script.Parent:WaitForChild("Sound")
local songs = {5034180086,1112199032,4513732143,4606400466,621227155} -- Songs go in here (ID ONLY)
local progress = main:FindFirstChild("ProgressBar").Progress
local songName = main:FindFirstChild("SongName")

-- Main Script

while wait() do -- Repeats itself continuously
    sound:Stop() -- Stops the music
    progress.Size = UDim2.new(0,0,1,0) -- Resets the song's progressbar
    if not sound.IsPlaying then -- If the song has stopped
        local songChosen = songs[math.random(1,#songs)] -- Chooses a random sound
        local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the sound's info
        sound.SoundId = "rbxassetid://".. songChosen
        sound:Play()
        songName.Text = asset.Name -- Changes to text to the sound's name
        wait(1) -- Prevents errors
        progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1) -- Moves progress bar
        wait((sound.TimeLength)-1) -- Waits sound's time -1
    end
end
end)
0
I put this script in this properties it's work [Starter Gui > MusicGui (ScreenGui) > MasterScript (LocalScript)] crookmega312 -3 — 4y
0
it's not working crookmega312 -3 — 4y
Ad

Answer this question