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

Im trying to change a GUI text when a song is played. HELP!?

This is my script.

wait(3) if game.Workspace.Songs.Havana.IsPlaying then script.Parent.Text = "" end

1 comment

0

I was going to help you but I saw you had Havana there.

1 answer

Try this code but don't just copy and paste as it will not work, you must understand it first.

put this code in a local script inside the text you want to change

first we want to create a variable to find the music

local musicFolder = game.Workspace:WaitForChild("Songs")

then we are going to want to create a function to change the text to whatever song is playing

function changeText()
    for i, v in pairs(musicFolder:GetChildren()) do 
        if v.IsPlaying == true then
            script.Parent.Text = "Current song playing: " .. v.Name
        end
    end
end

now what this function does is it runs through the children in musicFolder with a for loop. Each song that is in that folder will be assigned to variable v when it is in that part of the loop. Then we put an if statement to check if v.IsPlaying is a true value and if it is it will change the text to "Current song playing: song name".

We are not done yet we need to call this function somehow. You would use a remote event to trigger this. I will let you figure out the rest! here is a helpful link to remote events:

http://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

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