I’m developing a game that focuses on “Legacy” Roblox. I used the legacy animation scripts Animate.lua (5.2 KB) and noticed that when jumping, the character walks.
I am not a scripter, I am a builder. Could someone possibly review the lua file and possibly help with this? If not, it’s fine. It doesn’t hurt much.
Below you can watch a video of what I mean. I was testing the game on a chromebook I have.
The game needs alot of work, and I wanted to test the hardware quality for this poor celeron. Expect terrible footage.
Because I can’t script. The rbxl file is no different than a new world. It contains buildings and my own models. The skybox was the official 2012 starter place. The animations script may or may not be official, but I assume it is,. That is really the only script in game, and was wanting to someone to fix the above bug as I have no experience in scripting.
Is that script part of your Player’s Character object? If it is, then It is normal, (Check your StarterPlayer > StarterPlayerScripts / StarterCharacterScripts folder and tell if any). Also, can you refer the originating point of this script, i.e. Where it is located?
if you’re planning on making it authentic as possible, then this isn’t a bug.
however, i fixed it for you. the problem is that the script assumes when a player isn’t moving that its speed should equal zero. in programming, remember that nothing with extreme precision is actually gonna equal zero. instead it’ll be something like 0.000521.
i removed some bad practices. but this is legacy code for a reason. i left some annotations on things to fix.
--!strict
local Figure = script.Parent
local Torso = Figure:WaitForChild("Torso")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local RightHip = Torso:WaitForChild("Right Hip")
local LeftHip = Torso:WaitForChild("Left Hip")
local Neck = Torso:WaitForChild("Neck")
local Humanoid = Figure:WaitForChild("Humanoid") :: Humanoid
local pose = "Standing"
local toolAnim = "None"
local toolAnimTime = 0
local halfPi = math.pi / 2
local jumpMaxLimbVelocity = 0.75
function onRunning(speed)
if speed>Humanoid.WalkSpeed - 1 then --gosh knows why i put a -1 there but it works so i dont touch it.
pose = "Running"
else
pose = "Standing"
end
end
function onDied()
pose = "Dead"
end
function onJumping()
pose = "Jumping"
end
function onClimbing()
pose = "Climbing"
end
function onGettingUp()
pose = "GettingUp"
end
function onFreeFall()
pose = "FreeFall"
end
function onFallingDown()
pose = "FallingDown"
end
function onSeated()
pose = "Seated"
end
function onPlatformStanding()
pose = "PlatformStanding"
end
function moveJump()
RightShoulder.MaxVelocity = jumpMaxLimbVelocity
LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
RightShoulder:SetDesiredAngle(math.pi)
LeftShoulder:SetDesiredAngle(-math.pi)
RightHip:SetDesiredAngle(0)
LeftHip:SetDesiredAngle(0)
end
function moveSit()
RightShoulder.MaxVelocity = 0.15
LeftShoulder.MaxVelocity = 0.15
RightShoulder:SetDesiredAngle(halfPi)
LeftShoulder:SetDesiredAngle(-halfPi)
RightHip:SetDesiredAngle(halfPi)
LeftHip:SetDesiredAngle(-halfPi)
end
function animateTool()
-- all these ()'s? unnecessary.
if (toolAnim == "None") then
RightShoulder:SetDesiredAngle(1.57)
return
end
if (toolAnim == "Slash") then
RightShoulder.MaxVelocity = 0.5
RightShoulder:SetDesiredAngle(0)
return
end
if (toolAnim == "Lunge") then
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity = 0.5
RightHip.MaxVelocity = 0.5
LeftHip.MaxVelocity = 0.5
RightShoulder:SetDesiredAngle(halfPi)
LeftShoulder:SetDesiredAngle(1)
RightHip:SetDesiredAngle(halfPi)
LeftHip:SetDesiredAngle(1)
return
end
end
function move(deltaTime: number)
local amplitude
local frequency
if (pose == "Jumping") or (pose == "FreeFall") then
moveJump()
return
end
if (pose == "Seated") then
moveSit()
return
end
local climbFudge = 0
if (pose == "Running") then
if (RightShoulder.CurrentAngle > 1.5 or RightShoulder.CurrentAngle < -1.5) then
RightShoulder.MaxVelocity = jumpMaxLimbVelocity
else
RightShoulder.MaxVelocity = 0.15
end
if (LeftShoulder.CurrentAngle > 1.5 or LeftShoulder.CurrentAngle < -1.5) then
LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
else
LeftShoulder.MaxVelocity = 0.15
end
amplitude = 1
frequency = 9
elseif (pose == "Climbing") then
RightShoulder.MaxVelocity = 0.5
LeftShoulder.MaxVelocity = 0.5
amplitude = 1
frequency = 9
climbFudge = 3.14
else
amplitude = 0.1
frequency = 1
end
local desiredAngle = amplitude * math.sin(deltaTime*frequency)
RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
RightHip:SetDesiredAngle(-desiredAngle)
LeftHip:SetDesiredAngle(-desiredAngle)
local tool = Figure:FindFirstChildWhichIsA("Tool")
if tool then
local animStringValueObject = tool:FindFirstChild("toolanim")
if animStringValueObject then
toolAnim = animStringValueObject.Value
animStringValueObject.Parent = nil
toolAnimTime = deltaTime + .3
end
if deltaTime > toolAnimTime then
toolAnimTime = 0
toolAnim = "None"
end
animateTool()
else
toolAnim = "None"
toolAnimTime = 0
end
end
Humanoid.Died:Connect(onDied)
Humanoid.Running:Connect(onRunning)
Humanoid.Jumping:Connect(onJumping)
Humanoid.Climbing:Connect(onClimbing)
Humanoid.GettingUp:Connect(onGettingUp)
Humanoid.FreeFalling:Connect(onFreeFall)
Humanoid.FallingDown:Connect(onFallingDown)
Humanoid.Seated:Connect(onSeated)
Humanoid.PlatformStanding:Connect(onPlatformStanding)
Humanoid.Swimming:Connect(onRunning)
while Figure.Parent~=nil do --RUN SERVICE shouldve been used here. i dont even know how to convert it because of how old it is.
local _, deltaTime = wait(0.1)
move(deltaTime)
end