I made a running animation that replaces the default running animation when you have a tool equipped, so that the tool doesn’t bob up and down so much, but if you are running and you equip the tool while running it does not play my running animation until the player stops moving.
This is a short code that replaces only one AnimationId
local tool = script.Parent
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Equipped:Connect(function()
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
playingTracks:Stop(0)
end
local animateScript = script.Parent.Parent:WaitForChild("Animate")
script.Parent.runValue.Value = animateScript.run.RunAnim.AnimationId
animateScript.run.RunAnim.AnimationId = "rbxassetid://616163682" -- Run
end)
tool.Unequipped:Connect(function()
local humanoid = script.Parent.Parent.Parent.Character :WaitForChild("Humanoid")
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
playingTracks:Stop(0)
end
local animateScript = script.Parent.Parent.Parent.Character:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = script.Parent.runValue.Value -- Run
end)
What you showed in the video already works for me, the problem is that I can’t get my running animation to stop the default running animation from playing if I pull out the tool while my character is moving.
You don’t need any plugins, just copy and paste the code in LocalScript in Tool
Run the code in Studio before changing anything
local tool = script.Parent
tool.RequiresHandle = false
tool.CanBeDropped = false
tool.Equipped:Connect(function()
if not script:FindFirstChild("unequi") and not script:FindFirstChild("equi") then
local animateScript = script.Parent.Parent:WaitForChild("Animate")
local unequi = Instance.new("Animation")
unequi.Name = "unequi"
unequi.AnimationId = animateScript.run.RunAnim.AnimationId
unequi.Parent = script
local equi = Instance.new("Animation")
equi.Name = "equi"
equi.AnimationId = "rbxassetid://616163682"
equi.Parent = script
end
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local equi = humanoid:LoadAnimation(script.equi)
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
if playingTracks.Name == "RunAnim" then
equi:Play()
end
end
local animateScript = script.Parent.Parent:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = "rbxassetid://616163682" -- Run
end)
tool.Unequipped:Connect(function()
local humanoid = script.Parent.Parent.Parent.Character :WaitForChild("Humanoid")
local unequi = humanoid:LoadAnimation(script.unequi)
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
if playingTracks.Name == "RunAnim" then
unequi:Play()
end
end
local animateScript = script.Parent.Parent.Parent.Character:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = script.unequi.AnimationId -- Run
end)