game.Players.ChildAdded:connect(onPlayerEntered)
That depends on what the red underline is saying when you mouse over it.
You must use PlayerAdded
instead of ChildAdded
when you want to get the player that joined in the Players
service.. Try this instead:
game.Players.PlayerAdded:connect(function(player) -- whatever script you want to execute when someone joins end)
No stock function or void named onPlayerEntered
exists. When using PlayerAdded, the function's parenthesis refers to the player.
So, above i wrote function(player)
. This means that, the specific player that arrived will be referred to as player
. For instance, if a player called "CookieCrumbles" enters the server, player
shown above refers to game.Players.CookieCrumbles
.
Remember, events can be used at multiple targets at once, so if you want to make a multiplayer game, the event's function will execute for each player inside, and towards that player.