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

local players = game:GetService("Players") players.PlayerAdded:Connect(function(player) if player.Name == 'Mexual' then game.Players.Mexual.PlayerGui.OpEn.Frame.Visible = true end end)

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...

game.Players.PlayerAdded:Connect(function(plr)
    if plr.Name == "Mexual" then
        game.Players.Mexual.PlayerGui:WaitForChild("OpEn").Frame.Visible = true
else
    plr.PlayerGui:WaitForChild("OpEn").Frame.Visible = false
    end
end)

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

game.Players.PlayerAdded:Connect(function(plr)
    if plr.Name == "Mexual" then
        game.Players.Mexual.PlayerGui:WaitForChild("OpEn").Frame.Visible = true
    end
end)
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