Hey guys! I'm currently trying to make a game (like most of you) and I've ran into a problem... See in the past (3 years or so ago), I remember all you had to do to update your TextLabel or button etc. was to do something like this:
script.Parent.StarterGui.ScreenGui.Frame.TextLabel.Text = "WORK"
But now with a few updates they have seemed to change that and now you have to access the PlayerGui, and frankly I do not know how to do that, nor have I found a clear explanation on accessing it.
This is my attempt:
script.Parent.Parent.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Game is Starting in 30"
and it spits out "Players is not a valid member of Player" in ROBLOX Studio, but to my understanding Player is a part of Players.
Anyways I'd love it if someone explained to me how to access PlayerGui so I could progress my game, and possibly help other people who don't quite understand it as well.
Thanks!
Status: Solved!
It's rather simple to access it.
I'm not exactly sure what you're trying to get at with your script, but here's how I access it for one player:
game.Players.SouthCaroIina.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Game is Starting in 30"
If you're accessing multiple players then you would use pairs, like this:
for i, v in pairs(game.Players:GetChildren()) do --[[Here is where you would add if, then statements to only access certain players, as you probably know. But if you're accessing all of them, that is unnecessary.]] v.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Game is Starting in 30"
I'm going to assume that script.Parent.Parent is Workspace.
If you're literally trying to use LocalPlayer as to index the play using the script, I haven't ever done anything involving that before. I'd need further information to help anymore than this.
Well there are two methods I'm going to tell you, one server and one local.
The first (local script) is simply just using LocalPlayer:
game.Players.LocalPlayer.PlayerGui.Frame.TextLabel.Text = "it works lol"
now the second (server script) is using player added
game.Players.PlayerAdded:connect(function(player) player.PlayerGui.Frame.TextLabel.Text = "it works also" end)