Hello! I made a music script where the script takes music from ReplicatedStorage and plays it, it also shows the name of the music on a screen gui but its not working. the text does not change
here is my script:
local MusicFL = game.ReplicatedStorage.Musics local MusicText = game.StarterGui.MusicGui.MusicFrame.Title ---[Music1] - C418 - Familiar Faces ---[Music2] - C418 - Wet Hands ---[Music3] - C418 - Chirp ---[Music4] - C418 - Wait ---[Music5] - Interstellar - No time for caution ----------------- wait(3) MusicFL.Music1:Play() MusicText.Text = "C418 - Familiar Faces"--- song title change wait(119)---length of the music MusicFL.Music1:Pause()-- just to make sure wait(1)--pause between songs MusicFL.Music2:Play() MusicText.Text = "C418 - Wet Hands" wait(90) MusicFL.Music2:Pause() wait(1) MusicFL.Music3:Play() MusicText.Text = "C418 - Chirp" wait(198) MusicFL.Music3:Pause() wait(1) MusicFL.Music4:Play() MusicText.Text = "C418 - Wait" wait(238) MusicFL.Music4:Pause() wait(1) MusicFL.Music5:Play() MusicText.Text = "Interstellar - No time for caution" wait(248) print("Test")
also the music does play and it works the only thing that doesn't work is the text changing
First of all, make sure it's a localscript (obviously). Secondly, you're using StarterGui
. StarterGui immediately replicates everything to the Player.PlayerGui
. So you need to manipulate the PlayerGui
, not StarterGui
. I'll make the changes + some things you should know. (Don't use pause if you're planning to skip the song at the end). Note: You should use a folder and a for loop to optimise your code.
local musicFolder = game.ReplicatedStorage.Musics:GetChildren() --This sounds complicated, but it returns a table full of values, which is your music. local textLabel = script.Parent.Title --You should parent your TextLabel to the ScreenGui. You can use this or use this: game.Players.LocalPlayer:WaitForChild("PlayerGui").MusicGui.MusicFrame.Title for i, v in pairs(musicFolder) --This is a special for loop, which loops through tables. This is good for optimisation. textLabel.Text = v.Name --This gives the name of the song. You can use this. if v:IsA("Sound") then --This is just to check if it's sound. v:Play() v.Ended:Wait() --This event will only go through when the sound has ended. This is a better alternative than just looking at the timelength. end wait(1) end
A player's GUI and a GUI in StarterGui are different. If your script is local, you can do this:
local MusicFL = game.ReplicatedStorage.Musics local MusicText = game.Players.LocalPlayer.PlayerGui.MusicFrame.Title ---[Music1] - C418 - Familiar Faces ---[Music2] - C418 - Wet Hands ---[Music3] - C418 - Chirp ---[Music4] - C418 - Wait ---[Music5] - Interstellar - No time for caution ----------------- wait(3) MusicFL.Music1:Play() MusicText.Text = "C418 - Familiar Faces"--- song title change wait(119)---length of the music MusicFL.Music1:Pause()-- just to make sure wait(1)--pause between songs MusicFL.Music2:Play() MusicText.Text = "C418 - Wet Hands" wait(90) MusicFL.Music2:Pause() wait(1) MusicFL.Music3:Play() MusicText.Text = "C418 - Chirp" wait(198) MusicFL.Music3:Pause() wait(1) MusicFL.Music4:Play() MusicText.Text = "C418 - Wait" wait(238) MusicFL.Music4:Pause() wait(1) MusicFL.Music5:Play() MusicText.Text = "Interstellar - No time for caution" wait(248) print("Test")