Where would you put CharacterAdded() & PlayerAdded()

I sound stupid asf but I am having trouble with this

Ive tried LocalScripts and Scripts in StarterPlayerScripts & StarterCharacterScripts with simply this line and it doesnt seem to work:

game.Players.PlayerAdded:Connect(function(player)
	print("A player has entered: " .. player.Name)
end) --its literally the api copypaste

https://developer.roblox.com/en-us/api-reference/event/Players/PlayerAdded
https://developer.roblox.com/en-us/api-reference/event/Player/CharacterAdded

I usually do it like this:

game.Players.PlayerAdded:Connect(function(player)
	print("A player has entered: " .. player.Name)
    local character = player.Character
    if not character then
        character = player.CharacterAdded:wait()
    end
end) --its literally the api copypaste
1 Like

Where would this be best to insert thou?

If it’s a Script, meaning you want it to run on the server side, put it in ServerScriptStorage. If it’s a LocalScript, where you only want it running on the client, put it in StarterGui, StarterPlayerScripts, or StarterCharacterScripts. I personally prefer either of the first two.

1 Like