It says:
ServerScriptService.Script:5: attempt to index field 'PlayerGui' (a nil value)
Here's the part of the script:
players = game.Players:GetChildren() local textLabel = players.PlayerGui.ScreenGui.TextLabel
Is there something I'm doing wrong?
I assume you're using a server sided script because that error came from server script service.
You cannot access the PlayerGui
of a player using a server script. What you should do instead is put that in a local script and tweak it a little. You also tried to get PlayerGui
from a table named "players" which is a common mistake because :GetChildren()
is often misunderstood
local player = game:GetService("Players").LocalPlayer -- gets the player local textLabel = player:WaitForChild("ScreenGui"):WaitForChild("TextLabel") -- waits for the text label and returns it to textLabel, used :WaitForChild() incase they load late
Dude, take a 'ScreenGui' ; put that to 'StarterGui' and insert the things you wish into the ScreenGui. That's all !
You can access a player's PlayerGui's descendants when FE is disabled, but can't access them when FE is enabled.
Use a client - sided script, a.k.a LocalScript.