Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I go about playing a walking animation for a custom rig?

Asked by 4 years ago

Hello, so I've got this custom rig with a following script in it (not sure if that's necessary but I'll drop it at the bottom) and I'm wondering how I would go about playing a certain animation when they are walking. So far I have these 2 that sort of work together.

function onwalking(speed)
    if speed <= 0 then
        script.Parent.XenAnim.Disabled = true
    end
end

and then there's this one that it's disabling

local anim = script.Parent.Humanoid:Loadanimation(script.Test)

if script.Parent.XenAnim.Disabled == false then
    anim:Play()
end 

as well as the following script

function findNearestTorso(pos)
    local list = game.Workspace:children()
    local torso = nil
    local dist = 45
    local temp = nil
    local human = nil
    local temp2 = nil
    for x = 1, #list do
        temp2 = list[x] 
        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
            temp = temp2:findFirstChild("HumanoidRootPart")
            human = temp2:findFirstChild("Humanoid")
            if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
                if (temp.Position - pos).magnitude < dist then
                    torso = temp
                    dist = (temp.Position - pos).magnitude
                end
            end
        end
    end
    return torso
end




while wait() do
    wait(1)
    local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
    if target ~= nil then
        script.Parent.Humanoid:MoveTo(target.Position, target)
    end

end

These are all regular scripts directly parented to the model itself. Thank you!

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

Its perfectly fine if you use ROBLOX's Default script for animation.

  1. Go in game and open your character in workspace
  2. Copy Animate
  3. Paste it in your NPC / StarterCharacter
  4. Edit it and change walk then id and paste your ROBLOX animation there and do run and the same thing if that doesn't work.
  5. Then open the scripts arrow, Open walk arrow, Open Animation
  6. Paste your animation ID and your done!

Animate should be a localscript (Others can see it as it only plays animations.). You may also change the scripting to make the run animations. I'd recommend doing the run animations on your running script though as its not as buggy and delayed.

Ad

Answer this question