My character related functions don't seem to run inside CharacterAdded

game.Players.PlayerAdded:Connect(function(player)
Data.Load(SessionData, player)
player.CharacterAdded:Connect(function(character)
	Player.Scale(player, character)
	Player.EquipWeapon(SessionData[player.Name], character, Items.Info[SessionData[player.Name].Equipped.Weapon[1]], SessionData[player.Name].Equipped.Weapon[2])
	Player.EquipArmour(SessionData[player.Name], character, Items.Info[SessionData[player.Name].Equipped.Hat[1]], SessionData[player.Name].Equipped.Hat[2])
end)
end)

This is my code, it basically shrinks the player and equips the weapon and hat they have equipped. When I just click play in studio it looks like this:

But when I test on an actual server, it appears like this:

There are no errors.

I’ve tried solutions such as repeat wait() until player.Character and repeat wait() until workspace[player.Name] but they don’t seem to work. I presume the character doesn’t fully load in time, but the functions run anyway (would of thought they’d error though).

Does anyone know why it’s doing this??

EDIT: It’s just past midnight so I’m really sorry if i’m being stupid and it’s a really simple solution.

The experience I’ve had with test servers is extremely bad and buggy. What I’ve always done is to publish to the website and play tested from there, and now with being able to play your own games without making them public, there’s really no risk to that.

2 Likes

Just tested, it was studio being buggy. TYVM!

2 Likes

Does this line of code yield? It’s possible that you’re not connecting to CharacterAdded before the character loads.

Sometimes your player will be added before the script with your PlayerAdded connection runs, causing it not to fire in studio.

Try looping through Players:GetPlayers() and calling your desired functions on each player if the connections didnt fire.

2 Likes