Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this character loading script only work for the first player in the server?

Hey! I'm working on a custom character morphing system and although the following script works perfectly for the first player to enter a server, every other player that follows cannot load their character. I wonder if it's a deceptively simple problem and could really use some advice.

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.Died:connect(function()
				wait(4)
				player:LoadCharacter()
			end)
		end
	end)
	game.Lighting.StarterCharacter3.Parent = game.StarterPlayer
	game.StarterPlayer.StarterCharacter3.Name = 'StarterCharacter'
	player:LoadCharacter()
end)

1 comment

0

on line 13, you re-parent instead of :Clone() the instance.

2 answers

✓ Accepted answer

the character model is only moved into the StarterPlayer service after they join, and its nil when they join for the first time because it loads into the service after

1 comment

0

Oh thankyou

You shouldn't use Lighting as a method of storage anymore and I'm guessing the script breaks altogether because you're setting the parent of StarterCharacter3 to something else, meaning that the second time someone joins, it won't be indexed and your code will break at like 13 and it won't execute the code at line 15, which loads the player's character.

This discussion is preserved as it was. New answers, comments, and votes are closed.