Anyone got a better suggestion for how to play this idle animation?

I have an idle animation but for the life of me I cant get it to turn off when I unequip the weapon, even if it looks like it will itll just start back up the only solution I have found is removing it from the equipped function entirely, any better way to do tool idles besides just checking if the weapon is equipped?

Heres how I initialized the animations

local anim1 = Instance.new("Animation")
anim1.AnimationId = "http://www.roblox.com/Asset?ID=17446888463" -- FIRING ANIMATION
local anim2 = Instance.new("Animation")
anim2.AnimationId = "http://www.roblox.com/Asset?ID=17475676196" -- IDLE ANIMATION
local anim3 = Instance.new("Animation")
anim3.AnimationId = "http://www.roblox.com/Asset?ID=15791160658" -- RELOAD ANIMATION
local anim4 = Instance.new("Animation")
anim4.AnimationId = "http://www.roblox.com/Asset?ID=15792859003" -- CLICK ANIMATION
local anim5 = Instance.new("Animation")
anim5.AnimationId = "http://www.roblox.com/Asset?ID=17446951316" -- AIM ANIMATION
local track1, track2, track3, track4, track5

heres what animations 2 script looks like

local function playAnimation2()
	if not isPlaying then
		isPlaying = true
		local humanoid = game.Players.LocalPlayer.Character.Humanoid
		if track1 then
			track1:Stop()
		end
		if track2 then
			track2:Stop()
		end
		if track3 then
			track3:Stop()
		end
		track2 = humanoid:LoadAnimation(anim2)
		track2.Priority = Enum.AnimationPriority.Action
		track2.Looped = true
		task.wait()
		track2:Play()
	end
end

And heres the only time I activate it

tool.Equipped:Connect(function()
	isLooping = true
	equipped = true
	playAnimation2() -- Play idle animation when equipped
	createAmmoGui()
	setVolumesToDefault()
end)

Any help for a way to stop it would be nice and I’ve already tried all the basics so I’m trying to just find a more simple way to start it since equipped seems either to inefficient at detecting equips or it works to well and cant turn off

Did you try this?

tool.Unequipped:Connect(function()
	if track2 ~= nil then
		track2:Stop()
		track2 = nil
	end
end)

Nevermind I had the wrong script active this seems to work, it must have been the track2 = nil because I had a StopAnimation2() that made it stop but didn’t have the track2 = nil

1 Like

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