Character changes position when animated

I made a script that changes the appearance of a character using humanoid:ApplyDescription(). However, when the script is enabled and the character is animated, the character changes its position (see the second video). I have tried changing the position and orientation of the LowerTorso and HumanoidRootPart, but that did not work. Here is video of the problem I am having:

this is what happens when the script is disabled. this is what happens when the script is enabled.

The part is used to mark the position I want the character to go to when its appearance has been changed. Note that the HumanoidRootPart is anchored. Any help is appreciated!

Could you please let me know what you have tried so far? Some things I’m thinking off the top of my head are;

  • Check the output.
  • Another Script is messing with your character.
  • You may need to try it in another studio
  • You’re encountering a bug.

When asking for support, please provide things that you have tried so far to prevent people from asking you to do things you have already done. :slight_smile:

1 Like

I there is nothing in the output, no other scripts are messing with the character, and I tried it in another studio and I don’t believe that it is a bug. Things that I have tried so far are changing the position of the HumanoidRootPart and LowerTorso, and removing some things from the script. I believe that the problem is coming from humanoid:ApplyDescription(), because when I removed it from the script, the issue went away. The problem is, how can I change the appearance of the character and keep the same position as shown in the first video when animated?

What is the position of the character’s root part after this happens. Could it possibly be resetting the CFrame back to (0,0,0)?

1 Like

the character’s root part’s position and rotation are not affected.

I can’t think of a reason why :ApplyDescription() would change the position of your character
Although a workaround for this would be to log the CFrame of the humanoidrootpart before you apply it and then after its applied set the humanoidrootpart to the logged CFrame

Edit:

Then the animation itself is likely to be changing the position
Not :ApplyDescription()

1 Like

Then this means it is likely the animation itself which is changing the position of the character. Have you tried other animations as well?

1 Like

I have tried other animations, and their position has changed as well.

Could it be that one of the animation parts has been colliding into the ground which is causing the entire model to move up? Because it seems like this part(which is cancollide off) is refusing to collide through the baseplate. In the animation, I hid this part underneath the baseplate.
hi

If you are using props for your animations you might want to share the code with us so we can take a look and see what is going on.

1 Like
local humanoidrootpart=model.HumanoidRootPart
local humanoid=script.Parent.Humanoid
local test=script.Parent:GetDescendants()

for i,v in pairs(test)do

--Remove accessories
if v:IsA("Hat")or v:IsA("Shirt")or v:IsA("Pants")or v.Name=="Clothing" then
         v:Destroy()
    end
end

--save original C0 and C1 values from model

local Table = {}
local Neck = model.Head.Neck
local Waist=model.UpperTorso.Waist
local RightShoulder=model.RightUpperArm.RightShoulder
local LeftShoulder=model.LeftUpperArm.LeftShoulder
local RightElbow=model.RightLowerArm.RightElbow
local LeftElbow=model.LeftLowerArm.LeftElbow
local RightHip=model.RightUpperLeg.RightHip
local LeftHip=model.LeftUpperLeg.LeftHip
local RightKnee=model.RightLowerLeg.RightKnee
local LeftKnee=model.LeftLowerLeg.LeftKnee
local RightAnkle=model.RightFoot.RightAnkle
local LeftAnkle=model.LeftFoot.LeftAnkle
local RightWrist=model.RightHand.RightWrist
local LeftWrist=model.LeftHand.LeftWrist
local LowerTorso=model.HumanoidRootPart.LowerTorso
local BodyAttach=model.UpperTorso.BodyAttach
local DSM=model.RightHand.DSM

Table["1"] = Neck.C0

Table["2"] = Neck.C1

Table["3"] = Waist.C0

Table["4"] = Waist.C1

Table["5"] = RightShoulder.C0

Table["6"] = RightShoulder.C1

Table["7"] = LeftShoulder.C0

Table["8"] = LeftShoulder.C1

Table["9"] = RightElbow.C0

Table["10"] = RightElbow.C1

Table["11"] = LeftElbow.C0

Table["12"] = LeftElbow.C1

Table["13"] = RightHip.C0

Table["14"] = RightHip.C1

Table["15"] = LeftHip.C0

Table["16"] = LeftHip.C1

Table["17"] = RightKnee.C0

Table["18"] = RightKnee.C1

Table["19"] = LeftKnee.C0

Table["20"] = LeftKnee.C1

Table["21"] = RightAnkle.C0

Table["22"] = RightAnkle.C1

Table["23"] = LeftAnkle.C0

Table["24"] = LeftAnkle.C1

Table["25"] = RightWrist.C0

Table["26"] = RightWrist.C1

Table["27"] = LeftWrist.C0

Table["28"] = LeftWrist.C1

Table["29"] = LowerTorso.C0

Table["30"] = LowerTorso.C1

Table["31"] = BodyAttach.C0

Table["32"] = BodyAttach.C1

Table["33"] = DSM.C0

Table["34"] = DSM.C1

local playerId=113170969
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(playerId))
--changes character appearance

--attaches props to model
local M6D=Instance.new("Motor6D")
M6D.Name="BodyAttach"
M6D.Part0=model.UpperTorso
M6D.Part1=model.BodyAttach
M6D.Parent=model.UpperTorso

local M6D2=Instance.new("Motor6D")
M6D2.Name="DSM"
M6D2.Part0=model.RightHand
M6D2.Part1=model.DSM
M6D2.Parent=model.RightHand

--apply original C0 and C1 values to model
local NewNeck = model.Head.Neck
local NewWaist=model.UpperTorso.Waist
local NewRightShoulder=model.RightUpperArm.RightShoulder
local NewLeftShoulder=model.LeftUpperArm.LeftShoulder
local NewRightElbow=model.RightLowerArm.RightElbow
local NewLeftElbow=model.LeftLowerArm.LeftElbow
local NewRightHip=model.RightUpperLeg.RightHip
local NewLeftHip=model.LeftUpperLeg.LeftHip
local NewRightKnee=model.RightLowerLeg.RightKnee
local NewLeftKnee=model.LeftLowerLeg.LeftKnee
local NewRightAnkle=model.RightFoot.RightAnkle
local NewLeftAnkle=model.LeftFoot.LeftAnkle
local NewRightWrist=model.RightHand.RightWrist
local NewLeftWrist=model.LeftHand.LeftWrist
local NewLowerTorso=model.HumanoidRootPart.LowerTorso
local NewBodyAttach=model.UpperTorso.BodyAttach
local NewDSM=model.RightHand.DSM

NewNeck.C0 = Table["1"]

NewNeck.C1 = Table["2"]

NewWaist.C0 = Table["3"]

NewWaist.C1 = Table["4"]

NewRightShoulder.C0 = Table["5"]

NewRightShoulder.C1 = Table["6"]

NewLeftShoulder.C0 = Table["7"]

NewLeftShoulder.C1 = Table["8"]

NewRightElbow.C0 = Table["9"]

NewRightElbow.C1 = Table["10"]

NewLeftElbow.C0 = Table["11"]

NewLeftElbow.C1 = Table["12"]

NewRightHip.C0 = Table["13"]

NewRightHip.C1 = Table["14"]

NewLeftHip.C0 = Table["15"]

NewLeftHip.C1 = Table["16"]

NewRightKnee.C0 = Table["17"]

NewRightKnee.C1 = Table["18"]

NewLeftKnee.C0 = Table["19"]

NewLeftKnee.C1 = Table["20"]

NewRightAnkle.C0 = Table["21"]

NewRightAnkle.C1 = Table["22"]

NewLeftAnkle.C0 = Table["23"]

NewLeftAnkle.C1 = Table["24"]

NewRightWrist.C0 = Table["25"]

NewRightWrist.C1 = Table["26"]

NewLeftWrist.C0 = Table["27"]

NewLeftWrist.C1 = Table["28"]

NewLowerTorso.C0 = Table["29"]

NewLowerTorso.C1 = Table["30"]

NewBodyAttach.C0 = Table["31"]

NewBodyAttach.C1 = Table["32"]

NewDSM.C0 = Table["33"]

NewDSM.C1 = Table["34"]

Playing the animation is on another script. Sorry if the script is messy

Is there any other way to change a character’s appearance without using ApplyDescription?

There are multiple ways of changing the appearance, all of which are used for different circumstances. If all characters are going to be the same you can use the default character, or if you only want to change clothes (pants, shirt, tshirt) you can do that separately. What is your use case in this game?

1 Like

I want to create something where you would type a player’s name in a textbox to change a character’s appearance.

Here is a little more optimized code,

local humanoidRootPart = model.HumanoidRootPart
local humanoid = script.Parent.Humanoid

local Table = {}

function GetJoints(targetModel)

    local Joints = {

        Neck = targetModel.Head.Neck;
        Waist = targetModel.UpperTorso.Waist;
        RightShoulder = targetModel.RightUpperArm.RightShoulder;
        LeftShoulder = targetModel.LeftUpperArm.LeftShoulder;
        RightElbow = targetModel .RightLowerArm.RightElbow;
        LeftElbow = targetModel.LeftLowerArm.LeftElbow;
        RightHip = targetModel.RightUpperLeg.RightHip;
        LeftHip = targetModel.LeftUpperLeg.LeftHip;
        RightKnee = targetModel.RightLowerLeg.RightKnee;
        LeftKnee = targetModel.LeftLowerLeg.LeftKnee;
        RightAnkle = targetModel.RightFoot.RightAnkle;
        LeftAnkle = targetModel.LeftFoot.LeftAnkle;
        RightWrist = targetModel.RightHand.RightWrist;
        LeftWrist = targetModel.LeftHand.LeftWrist;
        LowerTorso = targetModel.HumanoidRootPart.LowerTorso;
        BodyAttach = targetModel.UpperTorso.BodyAttach;
        DSM = targetModel.RightHand.DSM
    }

    return Joints
end

-- Assuming this is a Script and not a LocalScript
game.Players.PlayerAdded:Connect(function(player)
    
    local character = player.Character or player.CharacterAdded:Wait()

    for _, item in pairs(character:GetChildren()) do -- Loops through all the children of the character.

        if item:IsA("Shirt") or item:IsA("Pants") or item.Name == "Clothing" then
            item:Destroy()
        end
    end
end)

local Joints = GetJoints(model)

for index, joint in ipairs(Joints) do

    table.insert(Table, #Table + 1, {joint.C0, joint.C1})
end

local playerId = 113170969
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(playerId))

local M6D = Instance.new("Motor6D")
M6D.Name = "BodyAttach"
M6D.Part0 = model.UpperTorso
M6D.Part1 = model.BodyAttach
M6D.Parent = model.UpperTorso

local M6D2 = Instance.new("Motor6D")
M6D2.Name = "DSM"
M6D2.Part0 = model.RightHand
M6D2.Part1 = model.DSM
M6D2.Parent = model.RightHand

-- Set new joints.
for index, joint in ipairs(Joints) do
    
    joint.C0 = Table[index][1]
    joint.C1 = Table[index][2]
end

I’m not sure if it works, if it doesn’t that’s okay.

It might be that animation piece as you said. Have you tried disabling animations?

Something else you could try is putting the humanoid in the sky. As you said there’s a prop piece below that will help you determine if that is the issue.

1 Like

Thank you! Unfortunately, I tested your script and it doesn’t work. Disabling the animation does nothing because the animation is the one that moves the character back to the block. It’s just that when the character changes appearance, its position becomes offset as shown in the second video.

I tried moving the LowerTorso using CFrame to the Part, but for some reason, the character’s position is different on the client than on the server:

Is there any explanation as to why this is happening?