Animation Don't load after changing animation id

so i did this script but i forget how to load animations help me pls.

local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 then
		print("its 8")
		if Animate.walk.WalkAnim.AnimationId == runanim then
			Animate.walk.WalkAnim.AnimationId = walkanim
			Humanoid:LoadAnimation(Animate.walk.WalkAnim)
		else
			print("its already walkanim")
		end
	else
		print("its 16")
		if Animate.walk.WalkAnim.AnimationId == walkanim then
			Animate.walk.WalkAnim.AnimationId = runanim
			Humanoid:LoadAnimation(Animate.walk.WalkAnim)
		else
			print("its already runanim")
		end
	end
end
1 Like

i will put this script into sprint script after i know it’s really bad i’m just doing for loading animations

1 Like
local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local RunAnimation = Instance.new("Animation")
local WalkAnimation = Instance.new("Animation")
RunAnimation.AnimationId = runanim
WalkAnimation.AnimationId = WalkAnimation
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 then
		print("its 8")
			local l = Humanoid:LoadAnimation(WalkAnimation)
            l:Play()
	else
		print("its 16")
			local l = Humanoid:LoadAnimation(RunAnimation)
            l:Play()
	end
end

This code should work! @AlienX1258

2 Likes

it repeats animation so fast i changed to this but still don’t working

local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local RunAnimation = Instance.new("Animation")
local WalkAnimation = Instance.new("Animation")
RunAnimation.AnimationId = runanim
WalkAnimation.AnimationId = walkanim
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 then
		print("its 8")
		if Animate.walk.WalkAnim.AnimationId == runanim then
			local l = Humanoid:LoadAnimation(WalkAnimation)
			l:Play()
		else
			print("Already Walking")
		end
	else
		print("its 16")
		if Animate.walk.WalkAnim.AnimationId == walkanim then
			local l = Humanoid:LoadAnimation(RunAnimation)
			l:Play()
		else
			print("its already running")
		end
	end
end
1 Like
local walk = false
local run = false

local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local RunAnimation = Instance.new("Animation")
local WalkAnimation = Instance.new("Animation")
RunAnimation.AnimationId = runanim
WalkAnimation.AnimationId = WalkAnimation
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 and walk == false then
        walk = true
        run = false
		print("its 8")
			local l = Humanoid:LoadAnimation(WalkAnimation)
            l:Play()
	elseif Humanoid.WalkSpeed == 16 and run == false then
        walk = false
        run = true
		print("its 16")
			local l = Humanoid:LoadAnimation(RunAnimation)
            l:Play()
	end
end
1 Like

it does moon walk xdd don’t stops even i stopped moving

1 Like

Try this then

local walk = false
local run = false

local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local RunAnimation = Instance.new("Animation")
local WalkAnimation = Instance.new("Animation")
RunAnimation.AnimationId = runanim
WalkAnimation.AnimationId = WalkAnimation
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 and walk == false then
        walk = true
        run = false
		print("its 8")
			local l = Humanoid:LoadAnimation(WalkAnimation)
            l:Play()
	elseif Humanoid.WalkSpeed ~= 8 and run == false then
        walk = false
        run = true
		print("its 16")
			local l = Humanoid:LoadAnimation(RunAnimation)
            l:Play()
	end
end
1 Like
local walkanim = "rbxassetid://9957775956"
local runanim = "rbxassetid://9957774022"
local RunAnimation = Instance.new("Animation")
local WalkAnimation = Instance.new("Animation")
RunAnimation.AnimationId = runanim
WalkAnimation.AnimationId = walkanim
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animate = script.Parent:WaitForChild("Animate")

while true do
	wait(0.5)
	if Humanoid.WalkSpeed == 8 then
		print("its 8")
			local l = Humanoid:LoadAnimation(WalkAnimation)
            l:Play()
	else
		print("its 16")
			local l = Humanoid:LoadAnimation(RunAnimation)
            l:Play()
	end
end

Should work with code.
And Idle is Stop() animate.