How do I edit a Textlabel in PlayerGUI?
The File Path is
game Players [Player] PlayerGui ScreenGui TextLabel.Text
Didn't work previously. Please help.
For Gui
s use a Local script
, only local scripts
work for Gui
s
Example code:
local player = game:GetService("Players").LocalPlayer local PlayerGui = player.PlayerGui PlayerGui.ScreenGui.TextLabel.Text = "Text here..."
What happened?
Well in your case you showed NO code so I will explain completely, 1st I grabbed the player and named him "player" (line 1) then I got the PlayerGui and named it "PlayerGui" (line 2) to brake down the code, on line three, I got the Text
within the TextLabel
and changed it to Text here...
I'm not the best at explaining but I hope this helps!
Thank you for accepting! Hope this helped!
It's best you break your Code down, trying to access something directly that far into an Instance may have chances of returning nil
. It's best to format it like so
local Player = game:GetService("Players").LocalPlayer --// Get's access to *your* player local PlayerGUI = Player:WaitForChild("PlayerGui") --// Get's access to *your* GUI local GUI = PlayerGUI:WaitForChild("ScreenGui").TextLabel --// Reference the TextLable Gui.Text = "Hello World!" --// Change Text
Be aware that GUI related Scripts should be handled by LocalScripts
, usually as a descendant of the GUIObject.
Don't forget!! When working with a Player's GUI, you must manipulate it from their PlayerGui
, not StarterGui
, that is the Server-side view of the UI, as of FE restrictions. Your screen will do nothing if you try from here.
Hope this helps!
(If there is anything you'd like clarification on or questions, please comment!)