PlayerAdded bug?

For some reason the code is only working for the first player that joins, anyone that could possibly know what the issue is please let me know

heres the code:



Could you show more code? This code doesn’t look to have any problems with it.
(EDIT: just tested it, it worked fine for me)

hey, thanks for the comment, the code might look a bit confusing because of my messy coding, basically it puts all the players in a table and when the game starts it teleports them onto 5 seperate platforms

1 Like

Before connecting PlayerAdded you should loop through Players:GetPlayers() to account for all players that have already connected to the server. Additionally, the player’s character may have already been created before you connect CharacterAdded so you would also need to account for that.

I’ve provided some example code here:

local function CharacterAdded(Character: Model)


local function PlayerAdded(Player: Player)
    if Player.Character then -- check if the character already exists for this player, if it does then CharacterAdded wont fire until they respawn.
    Player.CharacterAdded:Connect(CharacterAdded) -- fires when a new character is made

-- loop through all existing players and call PlayerAdded for them
for _, Player in Players:GetPlayers() do

Player.PlayerAdded:Connect(PlayerAdded) -- accounts for new players
1 Like

hm, its weird because the print worked, it printed player 1 and 2 joined, but for some reason did not copy over the values into the character

Likely because the players characters already exist when you connect CharacterAdded, refer to my code where I check if the character already exists before connecting CharacterAdded.

is this what it should look like? if so its not working

That’s beacuse due to the for loop, the playeradded connection is ignored, this is normal, you should do task.spawn on that loop instead. any yielding methods will void playeradded.