Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i get this text label for my joke game to change?

Asked by 5 years ago

the script is in the text label AND it's a local script

game.StarterGui.ScreenGui.TextLabel.Text = ("Jump over the garden wall NOW")
wait(1)
game.StarterGui.ScreenGui.TextLabel.Text = ("IDIOT LOL NOOB XD XD XD")
0
StarterGui is a storage location, nothing in there executes. You need to code your scripts so that they reference the copy of the contents that get copied into you Player.PlayerGui. This is normally done by using relative paths (e.g. script.Parent as root in place of game.StarterGui, when the Script prototype is a child of StarterGui) EmilyBendsSpace 1025 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

This is a classic mistake, I made it too. You see, 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: Using a static pathway

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

ScreenGui.TextLabel.Text = "Hello!"

Using a relative pathway:

local ScreenGui = script:FindFirstAncestorWhichIsA("ScreenGui")
local TextLabel = ScreenGui:FindFirstChildWhichIsA("TextLabel")

TextLabel.Text = "Hello!"

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

Ad

Answer this question