Changing player.Character doesn't work properly

Hello, my plan is to change the player’s character when pressing a button, I need to use player.Character because there’s multiple values (and other things) in the new character that I can’t be bothered to clone one by one. Upon pressing the button, it fires a remote, here’s the server script :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SelectEvent = ReplicatedStorage.Remotes:WaitForChild("CharacterSelect")

SelectEvent.OnServerEvent:Connect(function(plr, char1)
local char = ReplicatedStorage.Characters:FindFirstChild(char1):Clone() -- the new character
char.Name = plr.Name
char.Parent = workspace
plr.Character = char
end) 

The problem is that first of all, the camera isn’t set on the new character and doesn’t follow him, it gets stuck at the last place the first character was seen. Another issue is that the new one isn’t animated at all even though I originally copied him from my own character, with the “Animate” script existing.

1 Like

If you are changing the player’s character, you will also need to change the camera and clone some animation scripts into the new character model.

Player.Character cannot be modified.
This is changed and added by CoreScript.

1 Like

I was in a similar situation before. You just have to set the character of the player to the new character FIRST before parenting it to the workspace:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SelectEvent = ReplicatedStorage.Remotes:WaitForChild("CharacterSelect")

SelectEvent.OnServerEvent:Connect(function(plr, char1)
local char = ReplicatedStorage.Characters:FindFirstChild(char1):Clone() -- the new character
char.Name = plr.Name
plr.Character = char -- Set the new character first
char.Parent = workspace -- then parent it to the workspace
end) 

I assume that your problem for the animation will also be fixed as long as you set the character for the player correctly. However, just to be sure, I suggest that you make sure the new character is an exact duplicate of your original character and that none of the important parts (e.g. body parts, script, humanoid) were altered after customization.

I would like to just point out that the outline on “char” indicates that ROBLOX is already using it for an internal script, you may want to consider changing the variable name. That may come up as quite a problem while coding with built-in script names themselves.