Differences of playeradded and characteradded

Hello! i this post i want to know what are the differentes of PlayerAdded and CharacterAdded?

The PlayerAdded event fires when a player enters the game. This is used to fire an event when a player joins a game, such as loading the player’s saved GlobalDataStore data.

The CharacterAdded event fires when a player’s character spawns (or respawns). This event fires soon after setting Player.Character to a non-nil value or calling Player:LoadCharacter . Note, CharacterAdded fires when the Character is assigned to the Player , which is before the Character is parented to the Workspace .

4 Likes

And can they be used in a localscript or does the “getservice” only work in a server script?

:GetService works in all scripts and yes, events specified above works in localscripts too.

1 Like

game:GetService(“Players”) is basically the same as game.Players. GetService is mainly important for services that aren’t in the explorer, like game:GetService(“UserInputService”).

1 Like

Thanks you guys!

Am I using well my code to call when someoner respawn?

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
	print(player.Name .. " joined the game!")
	player.CharacterAdded:Connect(function(character)
		print("Spawn")
	end)
end)

Players.PlayerRemoving:Connect(function(player)
	print(player.Name .. " left the game!")
end)
2 Likes

Yes, that script will print “Spawn” when someone spawns in. I suggest making a new thread for each new question. Makes it easier for people to see and respond.

2 Likes

Thanks a lot! I was not sure since the ide did not show me suggestions, how could i active it?

1 Like