Animation issue

Hi everyone,
I’m currently working on an Attack on Titan game, and I’ve implemented a system for shifting into a Titan. However, I’m encountering an issue with the animations (or possibly something else—I’m not entirely sure where the problem lies).

Sometimes (not always), when the player unshifts back to human form, the character’s arms end up in a strange position:

Bug

Here are the two animations I’m using:

  1. Hand Bite Animation:
    image
  2. Unshift Animation:
    image

The key script responsible for the Titan shifting system is quite complex. It changes the character model, loads new characters, uses a lot of task.wait calls, and involves other intricate logic. I’ve included the script below for reference:

-- The shifting script is detailed here
local ShiftEvent = game:GetService("ReplicatedStorage").Function.Shift
local EffectFolder = game:GetService("ServerStorage").Effect
local ShiftEffectF = EffectFolder.Shift
local titanModel = game:GetService("ServerStorage").Titan
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TransformationEffect = game:GetService("Lighting").Transformation

ShiftEvent.OnServerInvoke = function(plr:Player)
    local ShiftValue:BoolValue = plr:FindFirstChild("Shift")
    local CanChange:BoolValue = plr:FindFirstChild("CanChange")

    if not CanChange.Value then
        return
    end
    
    if not ShiftValue.Value then
        CanChange.Value = false

        local char = plr.Character
        local hum:Humanoid = char.Humanoid
        local hrp:Part = char.HumanoidRootPart
        local animator:Animator = hum.Animator
        local titan = titanModel:Clone()

        local AT = animator:LoadAnimation(script.HandBite)
        AT:Play()

        AT:GetMarkerReachedSignal("End"):Connect(function()
            for i, effect in ShiftEffectF:GetChildren() do
                local newEffect = effect:Clone()
                newEffect.Parent = char:FindFirstChild("UpperTorso")
            end
        end)
        AT.Stopped:Wait()
        AT:Stop()
        
        local Lightning = EffectFolder.Lightning:Clone()
        local TransformationSound = EffectFolder.Transformation:Clone()
        TransformationSound.Parent = Lightning
        TransformationSound:Play()
        
        hrp.Anchored = true
        plr.CameraMinZoomDistance = 100
        Lightning:PivotTo(char:GetPivot())
        Lightning.Parent = workspace
        
        titan:FindFirstChild("Controlled").Value = true
        titan:PivotTo(char:GetPivot())
        
        task.wait(1.5)
        
        titan.Parent = workspace
        Lightning:Destroy()
        plr.CameraMinZoomDistance = 10
        
        plr.Character = titan

        ShiftValue.Value = true
        CanChange.Value = true

        return titan
    else
        CanChange.Value = false

        local titan = plr.Character
        local humT:Humanoid = titan.Humanoid
        local animatorT:Animator = humT.Animator
        local hrpT:Part = titan.HumanoidRootPart

        local AT = animatorT:LoadAnimation(script.Unshift)
        hrpT.Anchored = true
        AT:Play()

        AT:GetMarkerReachedSignal("End"):Connect(function()
            AT:AdjustSpeed(0)
        end)

        AT:GetMarkerReachedSignal("End"):Wait()

        plr:LoadCharacter()

        titan = titan:Clone()
        humT = titan.Humanoid
        animatorT = humT.Animator
        hrpT = titan.HumanoidRootPart

        titan:FindFirstChild("Controlled").Value = false
        titan.Parent = workspace

        RunService.Heartbeat:Wait()
        
        animatorT = titan:FindFirstChild("Humanoid").Animator
        AT = animatorT:LoadAnimation(script.Unshift)
        AT:Play()
        AT.TimePosition = AT.Length * 0.9
        AT:AdjustSpeed(0)

        local char = plr.Character
        local hum:Humanoid = char.Humanoid
        local animator:Animator = hum.Animator
        local hrp:Part = char.HumanoidRootPart

        local weld = Instance.new("WeldConstraint")
        char:PivotTo(titan.VitalPoint.CFrame)

        weld.Parent = titan.VitalPoint
        weld.Part0 = titan.VitalPoint
        weld.Part1 = hrp

        hum.PlatformStand = true
        titan.VitalPoint.Smoke.Enabled = true

        task.wait(2)

        weld:Destroy()
        titan.VitalPoint.Smoke.Enabled = false
        hum.PlatformStand = false
        
        

        humT:Destroy()

        ShiftValue.Value = false
        CanChange.Value = true
    end
end

This is what it looks like in-game when the player shifts and unshifts:
View Animation Example

Does anyone have any suggestions on how to troubleshoot or fix this issue?
I suspect that it might be related to:

  1. Animations not resetting properly.
  2. Issues with the character rig or welds during the transition.

Any insights or advice would be greatly appreciated! Thanks in advance.

2 Likes

Hello, this is an issue with the Roblox Animation system. I don’t know a fix, but I recommend using MoonAnimator, as it does fix this issue.

Here is also a free animation plugin I used to use (I don’t know if it still works) Legacy Animation Editor

This does not appear to be a weld error due to the fact that the weld is being made on the HumanoidRootPart and not the left arm of the character, but in the event that it is, then the issue may be that the weld is sometimes being deleted before the animation is finished, leaving the player in an odd position. A solution would be to add an animation marker at the point where you want the weld to be deleted, and remove the weld through the animation marker.
If the issue is in the animations, then calling an Animation:Stop() when the animation is finished could help with that, although you will probably want to run a print statement at the end of the animation to be totally sure if that is the issue. Again though, using animation markers will help at least narrow the problem down a bit.