The code works now, and the animation plays, but the animation doesn’t flow back to the walking or idle animations smoothly.
Here is the code, It is stored in ServerScriptService under a folder called AnimationManagement:
--Services
local Players = game:GetService("Players")
--Variables
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://16754777947"
Players.PlayerAdded:Connect(function(plr)
--Variables
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local runAnimationTrack
humanoid.Running:Connect(function(speed: number)
print(speed)
if speed > 25 then
--Run Animation
runAnimationTrack = humanoid:LoadAnimation(runAnimation)
if not runAnimationTrack.IsPlaying then
runAnimationTrack:Play(0.1)
end
elseif speed == 0 then
--Stop Animation
runAnimationTrack:Stop()
end
end)
end)