Tool Walk Animation

I’ve made a walk animation for my tool but whenever I try to swap the current walk animation for the tools in the animate script it doesn’t work. any ideas as to what’s going wrong?

task.wait(.5)

local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")

local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")

local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1


local idletrack = Humanoid:LoadAnimation(idleAnim)


idletrack.Priority = 0


tool.Equipped:Connect(function()
	
	game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://15372964157"
	Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
	
	idletrack:Play()
	
end)

tool.Unequipped:Connect(function()
	
	game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://11588923735"
	Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
	
	idletrack:Stop()
end)

3 Likes
  1. Where you load animation for idle?
  2. What is this?

Why you try to change Priority to 0? I think it won’t work. Instead you need to use Enum.AnimationPriority

2 Likes

You will have to make a walk animation just how you did your idle animation. As far as I am awere of, changing the property won’t work, unless you do it before it’s loaded. This is because it just uses the properties once, at the beginning.

and for some reason

still works as i’ve tried it with other animations which yeilds the same result as Enum.AnimationPriority

2 Likes

So I should use UserInput Service? Or is there a Humanoid State for when the Player is walking?

1 Like

You can use the StateChanged event from the Humanoid

1 Like

Sorry about first, I didn’t see(I really didn’t even after put second question about it’s priority💀), but why you won’t just change basic animation instead of playing it by script?
Also, use RunAnim instead of WalkAnim.
Like this:

game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = "rbxassetid://15372964157"

WalkAnim is for example used by joystick on phone when you it isn’t on max distance from it’s starting position.

1 Like

the game I’m trying to make is going to just be pc as I’m not that well experienced in scripting so I’m not planning on adding any mobile or console support in a while or at all if I can actually finish it

1 Like

I think you didn’t understand me. WalkAnim isn’t used on PC, use RunAnim instead.
Fixed code:

task.wait(.5)

local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")

local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")

local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1


local idletrack = Humanoid:LoadAnimation(idleAnim)


idletrack.Priority = 0


tool.Equipped:Connect(function()
	
	game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = "rbxassetid://15372964157"
	Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
	
	idletrack:Play()
	
end)

tool.Unequipped:Connect(function()
	
	game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = "rbxassetid://11588923735"
	Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
	
	idletrack:Stop()
end)
1 Like

Unfortunately, the code still doesn’t work when I changed it to the Running animation but I’m currently trying to use the StateChanged event to play the animation

1 Like

I think it’s just problem in priorty. To which Priority changes idletrack’s Priority after you set it to zero?

1 Like

Like I said, use Humanoid.StateChanged. Documentation

1 Like

this is what I’ve got so far but when the player stops moving the animation doesn’t stop:

task.wait(.5)

local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")

local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")

local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1


local idletrack = Humanoid:LoadAnimation(idleAnim)
local walkTrack = Humanoid:LoadAnimation(walkAnim)

idletrack.Priority = 0

tool.Equipped:Connect(function()
	
	Humanoid.Running:Connect(function()
		walkTrack:Play()
	end)
	
	Humanoid.StateChanged:Connect(function(old, new)
		if new ~= Enum.HumanoidStateType.Running then
			walkTrack:Stop()
		end
	end)
	
	idletrack:Play()
	
end)

tool.Unequipped:Connect(function()
	walkTrack:Stop()
	idletrack:Stop()
end)

1 Like

you need to edit the default animate script and replace it because the default ids are already in the script

2 Likes

I’m not trying to make a default walk animation. I’m trying to make it so when the tool is equipped a different walk animation plays

1 Like

I figured it out using the Humanoid.Running function. Here is the script for anyone who may need it:

local Player = game.Players.LocalPlayer

task.wait(.5)

repeat wait() until Player.Character

--Variables

local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")

local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")

local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1


local idletrack = Humanoid:LoadAnimation(idleAnim)
local walkTrack = Humanoid:LoadAnimation(walkAnim)

idletrack.Priority = 0
walkTrack.Priority = 1

local equipped = false


--Main Script

tool.Equipped:Connect(function()  --tool idle
	equipped = true
	
	idletrack:Play()
	
end)

tool.Unequipped:Connect(function() --Stops animations
	equipped = false
	
	walkTrack:Stop()
	idletrack:Stop()
end)

Humanoid.Running:Connect(function(speed) --walk animation
	
	if equipped == true and speed > 0 then
		walkTrack:Play()
	end
	
	if speed == 0 then
		walkTrack:Stop()
	end
end)

NOTE: not the best way to do it but it works

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.