Custom Character for a specific player script not working

I’m trying to make a script that gives a certain player a custom character.
I’ve looked around everywhere (devforums, scripthelpers) for solutions, and also asked some friends about it and I ended up with this:

game.Players.PlayerAdded:Connect(function(player)
	local char = game.ServerStorage.CustomCharacter
	 
if player.UserId == 2983919658 then -- change the id to yours
		player.Character = char:Clone()
		player:LoadCharacter()
	end
end)

There are no errors in the Output, but the character isn’t given to the player.
Could anybody help?

2 Likes

You will probably want to create a custom character loading system.

There is one on the DevHub which works well.


-- Stop automatic spawning so it can be done in the "PlayerAdded" callback
game.Players.CharacterAutoLoads = false
 
local respawnDelay = game.Players.RespawnTime

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		-- find the humanoid, and detect when it dies
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.Died:Connect(function()
				wait(respawnDelay)
				player:LoadCharacter()
			end)
		end
	end)
	player:LoadCharacter() -- load the character for the first time
end)

If you are not using a custom rig you can convert the Character to a HumanoidDescription and then do
Player:LoadCharacterWithHumanoidDescription()

You will find that Changing the Player.Character to another rig will kill the player because there are two humanoids. The way around it is to simply delete the Humanoid in the target destination. Switch the character then add the Humanoid after.

Oh and if you are using a custom character instead of loading the character you want to spawn the model then change the players character to the model.

3 Likes

You’re just cloning the model and resetting the character.

Try to put the model inside the StarterCharacter, this dosent require any scripts though.

2 Likes

I used some help from a friend to understand this a bit better, and all I can say is that this is very efficient :slight_smile:

1 Like

I was aiming at making a custom character for a specific player, not everybody. Thank you though!

1 Like