Hi devs,
I have recently been trying to change the players character in game.
For some reason, the character just gets deleted, and doesn’t give the player a new character. I added a print statement (not included) to check that the function was being called when needed, which it was. Here’s my code
‘’
local function avatarCharLoad(plr)
local oldCharacter = plr.Character
local newCharacter = game:GetService(“ServerStorage”):WaitForChild(“Players”):FindFirstChild(plr.Name):Clone()
Dug up an old morph handler script I used to use that still works. Here’s what I used:
local charClone = morph:Clone()
local rootPart = charClone:FindFirstChild("HumanoidRootPart")
local plrRoot = plr.Character:FindFirstChild("HumanoidRootPart")
plr.Character = charClone
charClone.Parent = workspace
if rootPart and plrRoot then
rootPart.CFrame = plrRoot.CFrame
end
Adjusting this to your needs:
local function avatarCharLoad(plr)
local morph = game:GetService("ServerStorage"):WaitForChild("Players"):FindFirstChild(plr.Name)
local charClone = morph:Clone()
local rootPart = charClone:FindFirstChild("HumanoidRootPart")
local plrRoot = plr.Character:FindFirstChild("HumanoidRootPart")
plr.Character = charClone
charClone.Parent = workspace
if rootPart and plrRoot then
rootPart.Anchored = false
rootPart.CFrame = plrRoot.CFrame
end
end