I'm making a zombie that can lose his limbs, and for exemple, when he loses a leg, I want him to hop on one leg instead of continuing with his default run animation. I've tried editing the animate script with some ifs, but he just does nothing now when he loses a leg. So does anyone have an idea how I would go about this?
Below are the two functions I changed, I also added my "hop" animation to the animation table in the default "Animate" script by roblox.
function onRunning(speed)
if speed > 0.5 then
local scale = 16.0
if script.Parent:findFirstChild("RightUpperLeg") == nil or script.Parent:findFirstChild("LeftUpperLeg") == nil then
playAnimation("hop", 0.2, Humanoid)
else
playAnimation("walk", 0.2, Humanoid)
end
setAnimationSpeed(speed / scale)
pose = "Running"
else
if emoteNames[currentAnim] == nil then
playAnimation("idle", 0.2, Humanoid)
pose = "Standing"
end
end
end
function stepAnimate(currentTime)
local amplitude = 1
local frequency = 1
local deltaTime = currentTime - lastTick
lastTick = currentTime
local climbFudge = 0
local setAngles = false
if (jumpAnimTime > 0) then
jumpAnimTime = jumpAnimTime - deltaTime
end
if (pose == "FreeFall" and jumpAnimTime <= 0) then
playAnimation("fall", fallTransitionTime, Humanoid)
elseif (pose == "Seated") then
playAnimation("sit", 0.5, Humanoid)
return
elseif (pose == "Running") then
if script.Parent:findFirstChild("RightUpperLeg") == nil or script.Parent:findFirstChild("LeftUpperLeg") == nil then
playAnimation("hop", 0.2, Humanoid)
else
playAnimation("walk", 0.2, Humanoid)
end
elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
stopAllAnimations()
amplitude = 0.1
frequency = 1
setAngles = true
end
-- Tool Animation handling
local tool = Character:FindFirstChildOfClass("Tool")
if tool and (tool.RequiresHandle or tool:FindFirstChild("Handle")) then
local animStringValueObject = getToolAnim(tool)
if animStringValueObject then
toolAnim = animStringValueObject.Value
-- message recieved, delete StringValue
animStringValueObject.Parent = nil
toolAnimTime = currentTime + .3
end
if currentTime > toolAnimTime then
toolAnimTime = 0
toolAnim = "None"
end
animateTool()
else
stopToolAnimations()
toolAnim = "None"
toolAnimInstance = nil
toolAnimTime = 0
end
end
