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

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

Asked by 6 years ago

This is my script.

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

0
I was going to help you but I saw you had Havana there. User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

Ad

Answer this question