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

Help With a Simple yet Complicated Script?

So I want to change a textlabel's text more than once in a startergui, but when I change it more than once it stays with the first change, please help me.

local textlabel = script.Parent.Parent.StarterGui.ScreenGui.intercom

while true do
	textlabel.Text = "hi"
	wait(1)
	textlabel.Text = "lol"
	wait(1)
	textlabel.Text = "gg noob"
	wait(1)
end

1 comment

0

.> Dude, you are changing STARTER. Not the player's.

2 answers

Add this inside the text label


while true do
    script.Parent.Text = "hi"
    wait(1)
    script.Parent.Text = "lol"
    wait(1)
   script.Parent.Text = "gg noob"
    wait(1)
end

You were trying to change the STarterGui, which means it would stay as was on players but for new players it is the next text, but again doesn't change until new player or respawn. So if you add this script into the textlabel it will use script.Parent.Text to change it without a super long link.

StarterGui is a special folder that copies its contents to each player's PlayerGui. We do not edit the StarterGui folder, but rather write our script as if the Gui is already in the player's PlayerGui, like this. As you can see, when the game ran, the ScreenGui that was in StarterGui was copied and sent to my PlayerGui. So, we place our ScreenGui in StarterGui, and edit our LOCAL! script like so:

--LocalScript, NOT just a Script. All ScreenGuis run on LocalScripts.

local textlabel = script.Parent.intercom --Wherever the intercom is located in your GUI

while true do
    script.Parent.Text = "hi"
    wait(1)
    script.Parent.Text = "lol"
    wait(1)
   script.Parent.Text = "gg noob"
    wait(1)
end

2 comments

0

My bad. Replace script.Parent with textlabel.

0

Thats nice and all but what if I want the change in the text in such a way that the the change can trigger a function or event?

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