Hello!
So, for some quick context, I’m forwarding this post for my friend who’s a new developer, and doesn’t have posting permissions here yet. I tried my best to help him with my limited knowledge, but we came up with no solutions.
He successfully scripted a functioning idle animation for his tool, but he wants the animation to stop when the character is moving - which is the part that doesn’t work.
For some added technical context, this is a LocalScript inside a tool named “Fists” in the StarterPack.
local tool = script.Parent
local fistidle = Instance.new("Animation")
fistidle.AnimationId = "rbxassetid://14025916833"
local players = game:GetService("Players")
local character = players.LocalPlayer.Character or players.LocalPlayer.CharacterAdded:Wait()
local walking = character:WaitForChild("Humanoid").MoveDirection.Magnitude
local track
tool.Equipped:Connect(function()
track = script.Parent.Parent.Humanoid:LoadAnimation(fistidle)
track.Priority = Enum.AnimationPriority.Action
track.Looped = true
track:Play()
end)
tool.Unequipped:Connect(function()
if track then
track:Stop()
end
end)
tool.Equipped:Connect(function()
if walking > 0 then
if track then
track:Stop()
end
end
end)
Any and all help is appreciated. Thanks!