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!
Its perfectly fine if you use ROBLOX's Default script for animation.
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.