Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I enable a Gui from a normal script? [Solved]

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?

1 answer

✓ Accepted answer

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

4 comments

0

local TextLabel thanks ;p

0

Thank you! This worked for me. By the way, it showed Regen wasn't a valid member of PlayerGui so i did "player.PlayerGui:WaitForChild("Regen"):FindFIrstChild("TextLabel")"

0

so, this "enables" a gui how?

0

He just has a small typo "TextLabel.Visile" should be "TextLabel.Visible" I'm pretty sure that should fix it.

This discussion is preserved as it was. New answers, comments, and votes are closed.