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

How to change text in gui using a script?

Hi! So I have a music playlist, in Workspace, and a GUI with a TextLabel in StarterGUI. In the music playlist script, I added some code attempting to make the TextLabel state what song was playing when it started to play. It worked for the first song, but not any song after. I also noticed that only when using the admin command ;refresh in HDAdmin, did the TextLabel state what song was playing correctly. I don't understand why this is happening, as there is no output error, and the script looks correct. Any help would be greatly appreciated!!!!

song1 = "http://www.roblox.com/asset/?id=4872114478" 
song2 = "http://www.roblox.com/asset/?id=423031173"
song3 = "http://www.roblox.com/asset/?id=4700827910"

local music = Instance.new("Sound") 
music.Archivable = true 
local SONGPLAYING = game.StarterGui.SongGUI.Frame.TextLabel

music.Parent = script.Parent 
music.Pitch = 1 
music.Volume = 1 
music.Looped = false
music.Name = "Player"


while (true) do
	--1--
wait(5)
print 'Playing Sound 1'
	music.SoundId = song1 
	SONGPLAYING.Text = "Playing: Goodnight n Say So - Mashup "
	music:play()
		wait(130) 
	--2--
print 'Playing Sound 2'
	music.SoundId = song2
	SONGPLAYING.Text = "Playing: Doja Cat - Trauma"
	music:play() 	
		wait(130)
	--3--
print 'Playing Sound 3'
	music.SoundId = song3
	SONGPLAYING.Text = "Playing: Doja cat - Cyber"
	music:play()
		wait(130)	
end

1 answer

The starter gui is a service that clones all its content in the player gui its no the real GUI

song1 = "http://www.roblox.com/asset/?id=4872114478" 
song2 = "http://www.roblox.com/asset/?id=423031173"
song3 = "http://www.roblox.com/asset/?id=4700827910"

local music = Instance.new("Sound") 
music.Archivable = true 
local Player = game.Players.LocalPlayer --local player its the player is executing the script (it must be a local script)
local PlayerGui = Player:WaitForChild("PlayerGui")
--I used wait for child because the gui take time to load
local SONGPLAYING = PlayerGui:WaitForChild("SongGUI"):WaitForChild("Frame"):WaitForChild("TextLabel")
--wait for child again

music.Parent = script.Parent 
music.Pitch = 1 
music.Volume = 1 
music.Looped = false
music.Name = "Player"


while (true) do
    --1--
wait(5)
print 'Playing Sound 1'
    music.SoundId = song1 
    SONGPLAYING.Text = "Playing: Goodnight n Say So - Mashup "
    music:play()
        wait(130) 
    --2--
print 'Playing Sound 2'
    music.SoundId = song2
    SONGPLAYING.Text = "Playing: Doja Cat - Trauma"
    music:play()    
        wait(130)
    --3--
print 'Playing Sound 3'
    music.SoundId = song3
    SONGPLAYING.Text = "Playing: Doja cat - Cyber"
    music:play()
        wait(130)   
end

Sorry for my english I hope u understand me

3 comments

0

I doesn't work. It might be because my script is in Workspace, and you said it must be a local script. Would making it a local script and still putting it in Workspace work?

0

@WakeUpSUBS

0

The local script its just for players, and no u cant execute a local script in the workspace, you can put it in starter gui or starter player

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