player.CharacterAdded not working after running functions

So I have a function that triggers when a player joins the game, and then another when the player spawns in. The problem is that whenever I add function to run after someone joins, the rest breaks and the function that listens for player spawns stops working.

 game.Players.PlayerAdded:Connect((function(player)
    --this will activate when a player joins the game for the first time ^^^
    print(player.name .. " joined the game!");

    playerCount = playerCount + 1
    StatInit(player)
    FirstJoinCheck(player)
    JoinIncrement(player)
    player.CharacterAdded:connect(function(character)
        print(character.Name .. " spawned into the game!");
        --this event will activate when a player "joins" the game (liike after respawning) ^^^

this breaks ^^

game.Players.PlayerAdded:Connect((function(player)
--this will activate when a player joins the game for the first time ^^^
print(player.name .. " joined the game!");

player.CharacterAdded:connect(function(character)
	print(character.Name .. " spawned into the game!");

this doesn’t ^^

It doesn’t actually error, and it runs code written after the functions in that same block of code, just not where it listens for a player spawn.

1 Like

player.CharacterAdded:connect (function(character)
maybe change this to Connect so:

player.CharacterAdded:Connect(function(character)
2 Likes

The characteradded event is being called after the character loads. Put it before the function calls.

3 Likes