So I'm trying to make a script that will pop up a GUI only when the player enters. Not when the player respawns.
This is what a tried.
function onEntered(player) game.Players.PlayerAdded:connect(onEntered) --Problem should be here. local Ent = Instance.new("ScreenGui") Ent.Parent = game.Players.LocalPlayer.PlayerGui --This is just the first part of my GUI script. end
When I test it there are no errors in the output.
Pleas help!
I noticed you are doing something wrong, the event isnt supposed to be inside the connected function. So at start, it would be:
function onEntered(player) end game.Players.PlayerAdded:connect(onEntered)
And another thing i noticed, is that you are using a localscript, that won't fix your problem. Put a script at workspace, and then, ur code, fixed the way i did and: FULL CODE:
function onEntered(player) local Ent = Instance.new("ScreenGui") Ent.Parent = player:WaitForChild('PlayerGui') end game.Players.PlayerAdded:connect(onEntered)
Why WaitForChild?, WaitForChild so it can load . Why player.PlayerGui?, LocalPlayer in localscripts gives to the current player, and not new player, so that is kinda a messup (even tough in this case it would work, this is most recommended).
Hope it works! If not tell output. ~marcoantoniosantos3