local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait(2)
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local UIS = game:GetService("UserInputService")
local idleAnim = animator:LoadAnimation(script:WaitForChild("Idle"))
local function isPlayerMoving(tool)
local character = tool.Parent
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
return humanoid.MoveDirection.Magnitude > 0
end
end
return false
end
script.Parent.Equipped:Connect(function()
if not isPlayerMoving(script.Parent) then
if not idleAnim.IsPlaying then
idleAnim:Play()
end
else
if idleAnim.IsPlaying then
idleAnim:Stop()
end
end
end)
I am not sure what I am doing wrong - I am trying to make a custom idle anim when a tool is equipped and the player is idle, and I am doing everything right to my understanding