CharacterAdded Event bug

  1. What do you want to achieve? CharacterAdded event working on first login.

  2. What is the issue?

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        print("DEBUG 1")

Sometimes this DEBUG 1 prints, other times don’t! In character respawn it works fine. But the problem its in first login on a server!

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried some many orders. Tried to wait character and so on.
1 Like

Depends on what you want, if you want something to happen to the character when their player joins the game just do

local character = player.CharacterAdded:Wait()
-- then proceed to do the rest of the script

CharacterAdded doesn’t work when you first load in the game, so you have to do something like this.

game.Players.PlayerAdded:Connect(function(plr)
    function charAdded(Char:Model)
        print("spawned")
    end

    plr.CharacterAdded:Connect(charAdded)

    repeat task.wait() until plr.Character
    charAdded(plr.Character)
end)
1 Like

CharacterAdded does work when you first load the game. It’s just that in studio the character can* load before even the function happens.

1 Like

looks like this worked! Thanks man!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.