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

How can you change a textlabel with a script?

Asked by 5 years ago
Edited 5 years ago

I am trying to make a game that automatically chooses maps (which I do not need help with) but there is a problem; when I try to change a textlabel in a ScreenGui with a script located anywhere (even if I make it a child of the textlabel) the script won't make it change. I put it in the script that chooses the maps, and the actual map choosing part works, but is there anything wrong with this line? It even prints but it doesn't change the label

print("castle was selected")
game.StarterGui.Status.e.Text = "The 'Castle' map has been chosen"

"Status" is the ScreenGui, and "e" is the TextLabel``

0
Try locating the TextLabel first (local e = game.StarterGui.Status.TextLabel) and then change it to (e.Text = "----") MArzalAlBuchariZ 33 — 5y
0
MArzalAlBuchariZ, that is basically what I did up there Boi52893642864912 69 — 5y

2 answers

Log in to vote
0
Answered by
Cyrakohl 108
5 years ago

You will need to access the player gui for any changes to display because when you change it in the starter gui it won’t be visible try

local Player = game.Players.LocalPlayer local PlrGui = Player:WaitForChild(“PlayerGui”)

local your gui = PlrGu:WaitForChild:(“yourscreengui”).something

Ad
Log in to vote
-1
Answered by 5 years ago

I am not a good scripter but I think you need a for loop, and change "StarterGui" to PlayerGui instead. Here is the script:

local Players = game:GetService("Players")
local player = Players:GetChildren()

for i,v in pairs(player) do
    v.PlayerGui.Status.e.Text = "The 'Castle' map has been chosen!"
end

I am not pro at scripting. I haven't tested the script above but I think it will work. If it works then let me know, if it doesn't then let me know too in the comments!

0
It doesn't really work because it thinks that Status is not a valid member of PlayerGui Boi52893642864912 69 — 5y
0
If it is not a valid member of PlayerGui it means either that you are accessing the contents of the PlayerGui through a Script (you should be using LocalScripts when accessing GUIs) or that you need to use :WaitForChild on Status in case it hasn't loaded yet. Rheines 661 — 5y
0
Rheines thank you I figured out something when you said to use a localscript Boi52893642864912 69 — 5y

Answer this question