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

I'm trying to make a script open a GUI for a certain person but it doesn't work?

Asked by
Mexual 2
5 years ago
Edited 5 years ago
1local players = game:GetService("Players")
2 
3 
4players.PlayerAdded:Connect(function(player)
5    if player.Name == 'Mexual' then
6        game.Players.Mexual.PlayerGui.OpEn.Frame.Visible = true
7    end
8end)

I have this code but it doesn't work, can someone tell me what's wrong with it? It's a localscript.

2 answers

Log in to vote
0
Answered by
gloveshun 119
5 years ago
Edited 5 years ago

make sure this srcipt is not in a localscript, and its not parent: replicatedfirst or Starer...

1game.Players.PlayerAdded:Connect(function(plr)
2    if plr.Name == "Mexual" then
3        game.Players.Mexual.PlayerGui:WaitForChild("OpEn").Frame.Visible = true
4else
5    plr.PlayerGui:WaitForChild("OpEn").Frame.Visible = false
6    end
7end)

i made if the player not the player the gui not be visible, and keep some seconds for the loading

0
It worked! THANKS! :D Mexual 2 — 5y
0
nope gloveshun 119 — 5y
Ad
Log in to vote
1
Answered by
TopBagon 109
5 years ago

the output says that "OpEn" isn't a valid member of PlayerGui which means that you need to wait until it loads, simply use - WaitForChild

1game.Players.PlayerAdded:Connect(function(plr)
2    if plr.Name == "Mexual" then
3        game.Players.Mexual.PlayerGui:WaitForChild("OpEn").Frame.Visible = true
4    end
5end)
0
still doesnt work, don't know why Mexual 2 — 5y
0
@top, i made if the player not the player the "GUI" not be visible, watch it. gloveshun 119 — 5y
0
ye my bad I only made the half part TopBagon 109 — 5y

Answer this question