New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Changing the text using an touch function script?

Asked by 8 days ago

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

Log in to vote
1
Answered by
Feahren 1746 Moderation Voter
8 days ago
Edited 8 days ago

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!

Ad

Answer this question