So I’m currently trying to create a script to play an animation when the character is idle, walking or running. My current problem is that the script seems to be apparently loading new animations instead of just playing and stopping them. If anyone has any idea or can point out a mistake i might’ve made then feel free.
local idleAnim = humanoid:LoadAnimation(assets.Anims[animtype].Idle)
local walkAnim = humanoid:LoadAnimation(assets.Anims[animtype].Walk)
local runAnim = humanoid:LoadAnimation(assets.Anims[animtype].Run)
local function steprender()
if humanoid.MoveDirection == Vector3.new() then
if state ~= "Idle" then
state = "Idle"
walkAnim:Stop()
idleAnim:Play()
runAnim:Stop()
end
else
if humanoid.WalkSpeed > 16 then
if state ~= "Run" then
state = "Run"
walkAnim:Stop()
idleAnim:Stop()
runAnim:Play()
end
else
if state ~= "Walk" then
state = "Walk"
walkAnim:Play()
idleAnim:Stop()
runAnim:Stop()
end
end
end
end
game["Run Service"].Heartbeat:Connect(function()
steprender()
end)
Some of the script might be missing since this is just an outtake of the main script.