#death animation --> ragdoll

1 messages · Page 1 of 1 (latest)

wanton rover
#

can someone help me figure out whats wrong with this script? (will paste soon b/c text limit)

#
local humanoid = npc:WaitForChild("Humanoid")
local ANIM_ID = "rbxassetid://137360031332391"
local dead = false

humanoid.BreakJointsOnDeath = true
humanoid.RequiresNeck = false

local function stopAnimations()
    local animator = humanoid:FindFirstChildOfClass("Animator")
    if animator then
        for _, track in ipairs(animator:GetPlayingAnimationTracks()) do
            track:Stop(0)
        end
    end
end

local function dropWeapon()
    local group = npc:FindFirstChild("AntiScaleGroup")
    if not group then return end
    local weapon = group:FindFirstChild("Weapon")
    if not weapon then return end
    weapon.Parent = workspace
    for _, v in ipairs(weapon:GetDescendants()) do
        if v:IsA("Motor6D") or v:IsA("Weld") or v:IsA("WeldConstraint") then
            v:Destroy()
        end
    end
    if weapon:IsA("BasePart") then
        weapon.Anchored = false
        weapon.CanCollide = true
    end
end ```
#
local function die()
    if dead then return end
    dead = true

    local root = npc:FindFirstChild("HumanoidRootPart")
    if root then
        root.Anchored = true
    end

    humanoid.AutoRotate = false
    humanoid.PlatformStand = true

    stopAnimations()

    local animator = Instance.new("Animator")
    animator.Parent = humanoid

    local anim = Instance.new("Animation")
    anim.AnimationId = ANIM_ID

    local track = animator:LoadAnimation(anim)
    track.Priority = Enum.AnimationPriority.Action4
    track.Looped = false
    track:Play()

    while track.Length == 0 do
        task.wait()
    end

    task.wait(track.Length)

    stopAnimations()
    local old = humanoid:FindFirstChildOfClass("Animator")
    if old then old:Destroy() end
    task.wait()

    if root then
        root.Anchored = false
    end
    task.wait()

    for _, motor in ipairs(npc:GetDescendants()) do
        if motor:IsA("Motor6D") then
            local p0, p1 = motor.Part0, motor.Part1
            if p0 and p1 then
                local a0 = Instance.new("Attachment")
                local a1 = Instance.new("Attachment")
                a0.CFrame = motor.C0
                a1.CFrame = motor.C1
                a0.Parent = p0
                a1.Parent = p1
                local socket = Instance.new("BallSocketConstraint")
                socket.Attachment0 = a0
                socket.Attachment1 = a1
                socket.Parent = p0
            end
            motor:Destroy()
        end
    end

    for _, part in ipairs(npc:GetDescendants()) do
        if part:IsA("BasePart") then
            part.Anchored = false
            part.Massless = false
            part.CanCollide = true
            part:SetNetworkOwner(nil)
        end
    end

    dropWeapon()
end

humanoid.HealthChanged:Connect(function(hp)
    if dead then return end
    if hp <= 0 then
        humanoid.Health = 0
        task.defer(die)
    end
end) ```
#

no errors in output

#

gonna go shower now will be afk for a bit

nova galleon
#

Turn off sword collision