This is probably the most confusing thing in the world for me, and i can never seem to figure it out. Let me just start simple here. I have a script in Workspace and I want it to make a TextLabel inside a ScreenGui visible. I have no clue how to access it from there.
TextLabel = game.Players.Name.PlayerGui.Regen.TextLabel TextLabel.Visible = false wait(3) TextLabel.Visible = true
I also tried "game.Players.PlayerName.Regen.TextLabel" but still not helping. Anyone know how to do that?
I assume that you want to turn player's TextLabel invisible. Your problem is that you didn't include Player
. By doing:
game.Players.Name.PlayerGui.Regen.TextLabel
You are "telling" the script to find player with name "Name" which doesn't have to exist.
to get player from ServerScript you may use PlayerAdded event
game.Players.PlayerAdded:connect(function(player) -- Player Variable end)
Now that we have Player variable we can access to the Player's PlayerGui.
The final script:
game.Players.PlayerAdded:connect(function(player) -- Player Variable local TextLabel = player.PlayerGui.Regen.TextLabel TextLabel.Visible = false wait(3) TextLabel.Visile = true end)
Note that this will happen when player joins the game.
To do this whenever you want just use LocalScript.
For Player variable type this:
local Player = game.Players.LocalPlayer -- This can be used only in LocalScripts