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

Changing the text using an touch function script?

I'm trying to change what the TextLabel says using a touch event script. I've tried this...

function Touch()
   game.StarterGui.TextLabel.Text = ("Who is Joe?")
   wait(5)
   game.StarterGui.TextLabel.Text = ("Joe Mama")
end

script.Parent.Touched:connect(Touch)

...but that did not work. It only stayed on Who is Joe? But it never got to Joe Mama. Do any of you know how this is done?

1 answer

StarterGui is actually a replication Service—or container. Anything within it is actually transferred to another folder called PlayerGui, where the authentic GUIs are actually stored, and updated in real-time.

Trying to address the UI from StarterGui will modify the respective descendant, however, it will not replicate, so for your Script to actually make amendments to the GUI you desire, you need to write this instead:

local Player = game.Players.LocalPlayer -- PlayerGui resides in the Client
local PlayerGui = Player:WaitForChild("PlayerGui")
local TextLabel = PlayerGui:WaitForChild("TextLabel")

TextLabel.Text = "Hello!"

Hope this helped! Remember to accept this answer if so!

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