Custom tool walking animation

what i want to achieve is when the player has the tool equipped and is walking it plays the custom animation.

the issue is when the player walks, it doesnt play the custom animation.

i have tried look around the dev hub for scripts but none of them seem to work

here is the script i am using

local tool = script.Parent
local char = game.Players.LocalPlayer.Character
local walk = script.Parent.Animations.Walk
tool.Equipped:Connect(function()

	game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = walk.AnimationId


end)

tool.Unequipped:Connect(function()

	game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://2510202577"


end)

help would be very help ful

4 Likes

I’ve not tested this very well, but it might just do the job. Make sure to adjust animation priority so that it trumps the default walking animation.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")


local Tool = script.Parent

-- Here we load our animation onto the Animator, located inside the Humanoid.
local Animation = Instance.new("Animation")
Animation.AnimationId = "http://www.roblox.com/Asset?ID=14146710555"
local Tool_Walk = Humanoid.Animator:LoadAnimation(Animation)


-- While tool is equipped, the Humanoid.Running event fires whenever a change in speed occurs.
-- We can use this to stop/start the animation and use isWalking as a debug bool value to make sure animations doesnt start/stop rapidly.
local isWalking = false
Humanoid.Running:Connect(function(speed)
	
	if Tool.Parent == Character then
		
		if speed > 0 and not isWalking then
			isWalking = true
			Tool_Walk:Play()
			
		elseif speed == 0 and isWalking then
			isWalking = false
			Tool_Walk:Stop()
		end
	end
end)


Tool.Equipped:Connect(function()

-- Starts animation if player is walking and equips tool
	if Humanoid.MoveDirection.Magnitude > 0 then
		isWalking = true
		Tool_Walk:Play()
	end
end)


Tool.Unequipped:Connect(function()
	
-- Stops animation if player is walking and unequips tool
	if Humanoid.MoveDirection.Magnitude > 0 then 
		isWalking = false
		Tool_Walk:Stop()
	end
end)

2 Likes

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