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

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


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

✓ Accepted answer

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

2 comments

0

It worked! THANKS! :D

0

nope

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)

3 comments

0

still doesnt work, don't know why

0

@top, i made if the player not the player the "GUI" not be visible, watch it.

0

ye my bad I only made the half part

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