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

How to show what song is playing in ScreenGUI?

So i'm making a game with music, and I want to show what song is playing in the corner of the screen. Can someone help me?

local Sound1 = game.Workspace.Sound.Sound1
local Sound2 = game.Workspace.Sound.Sound2
local Sound3 = game.Workspace.Sound.Sound3
local Sound4 = game.Workspace.Sound.Sound4
local Sound5 = game.Workspace.Sound.Sound5
local texty = game.StarterGui.ScreenGui.pp
------------------------------------------
while true do
	Sound1:Play()
	texty.Text = "Current Song: Driftveil City - Pokemon Black and White"
	Sound1.Ended:Wait()
	texty.Text = "Current Song: Stardust Speedway Past - Sonic CD"
	wait(2.5)
	Sound2:Play()
	Sound2.Ended:Wait()
	texty.Text = "Current Song: Dinklie -  BFB OST"
	wait(2.5)
	Sound3:Play()
	Sound3.Ended:Wait()
	texty.Text = "Current Song: Dire, Dire, Docks - Super Mario 64"
	wait(2.5)
	Sound4:Play()
	Sound4.Ended:Wait()
	texty.Text = "Current Song: Dire, Dire, Docks - Super Mario 64"
	wait(2.5)
	Sound5:Play()
	Sound5.Ended:Wait()
	wait(2.5)
end

2 comments

1

I think there is a Playing property of a song, maybe use the :GetPropertyChangedSignal to fire when it starts playing https://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal https://developer.roblox.com/en-us/api-reference/property/Sound/Playing

0

That would work, but sounds also have an ended event. Just wait for that. Song.Ended:Wait()

1 answer

Easiest solution would be to run a function that plays a song, waits for the song to end, then restarts the function with another sound.


--Assuming you have a folder inside replicated storage named "Audio" And a folder inside the "Audio" folder named "Soundtracks"
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Define RepStorage
local Soundtracks = ReplicatedStorage:WaitForChild("Audio"):WaitForChild("Soundtracks") -- Define song locations.
local songs = Soundtracks:GetChildren() -- Get all the songs.
local currentsong = 1 -- Define what song number we are on.
function playSong()
	local Song = songs[currentsong] -- Get the next song
	Song:Play() -- Play the next song
	gui.Text = "Playing: ".. Song.Name -- Update this line to modify the GUI you have.

	Song.Ended:Wait() --Wait for the song to end
	currentsong = currentsong + 1 -- Increase song number by 1 to play next song
	if currentsong > #songs then currentsong = 1 end -- If song number > # of songs, revert back to first song.
	playSong() -- Restart function
end

playSong() -- Start function
--This function will gather all of the songs, and play them in order.

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