Hello! My character’s walk animation plays when I unequip a weapon while walking. There is no problem when I stop with the tool, but when changing on or off when walking it bugs out.
-- Cancel all animations
local function STOPALL()
if DashAnim then
DashAnim:Stop()
end
if WalkAnim then
WalkAnim:Stop()
end
if RunAnim then
RunAnim:Stop()
end
if IdleAnim then
IdleAnim:Stop()
end
end
-- Idle animation
local function IDLE()
IsIdle = true
IsWalking, IsRunning = false, false
STOPALL()
if IdleAnim then
IdleAnim:Play()
end
local revertFOVTween = game.TweenService:Create(camera, TweenInfo.new(0.3), { FieldOfView = originalFOV })
revertFOVTween:Play()
end
-- Walking animation
local function WALKING()
IsWalking = true
IsIdle, IsRunning = false, false
STOPALL()
WalkAnim:Play()
end
-- Running animation
local function RUNNING()
IsRunning = true
IsWalking, IsIdle = false, false
STOPALL()
if RunAnim then
RunAnim:Play()
end
end
hum.Running:Connect(function(speed, gp)
if gp then return end
if hum.MoveDirection.Magnitude == 0 then
IDLE()
end
if hum.MoveDirection.Magnitude > 0 and IsInAir == false and not IsRunning then
hum.WalkSpeed = normspeed
WALKING()
end
end)
-- Character tool check
char.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") then
IsTool = true
IdleAnim:Stop()
LoadAnimations(tool)
if hum.MoveDirection.Magnitude == 0 then
IDLE()
end
end
end)
char.ChildRemoved:Connect(function(tool)
if tool:IsA("Tool") then
IsTool = false
IdleAnim:Stop()
LoadAnimations()
if hum.MoveDirection.Magnitude == 0 then
IDLE()
end
end
end)