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 make a script for Entered?

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!

1 answer

✓ Accepted answer

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

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