I just want to say sorry for the late replies because my internet keeps going on and off but, I have this script which plays an idle animation for a tool whenever the player is standing still with it equipped. Yes that part does work but the only thing is the animation does not stop whenever the tool is unequipped. It is as if the Running function ignored everything and won't stop when the tool is unequipped. (btw I did try ending the function sooner)
local Player = script.Parent.Parent.Parent
local Tool = script.Parent
local weld = Instance.new("Weld", Tool)
weld.Part0 = Tool.Blade
weld.Part1 = Player.Character:WaitForChild("GripBrick")
weld.C1 = CFrame.new(0, 0, -1) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(180))
--Sheathe-------------------------------------------------------------
local Sheathe = Tool.Sheathe
Sheathe.Parent = Player.Character
local weld = Instance.new("Weld",Sheathe)
weld.Part1 = Sheathe.HumanoidRootPart
weld.Part0 = Player.Character.Torso
weld.C0 = CFrame.new(0,-.25,0)
-------------------------------------------------------------------------
local Track1 = Instance.new("Animation")
Track1.AnimationId = "rbxassetid://6074005467"
local Equip = Player.Character.Humanoid:LoadAnimation(Track1)
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://6074005467"
local Unequip = Player.Character.Humanoid:LoadAnimation(Track2)
local Track3 = Instance.new("Animation")
Track3.AnimationId = "rbxassetid://6074686611"
local Idle = Player.Character.Humanoid:LoadAnimation(Track3)
-------------------------------------------------------------------------
Tool.Equipped:Connect(function()
Equip:Play()
Player.Character.Humanoid.Running:connect(function()
wait(1)
if Player.Character.Torso.Velocity.Magnitude < 0.2 then
Idle:Play()
elseif Player.Character.Torso.Velocity.Magnitude > 0.2 then
Idle:Stop()
end
--I tried adding the end) here, same issues
Sheathe.Blade.Transparency = 1
local b = Instance.new("BoolValue")
b.Parent = Player.Character
b.Name = "Equipped"
local bs = Instance.new("BoolValue")
bs.Parent = Player.Character
bs.Name = "Hit"
game.Debris:AddItem(bs,1)
Sheathe.Blade.Sheathe:Play()
Sheathe.Blade.Sheathe:Stop()
end)
Tool.Unequipped:Connect(function()
Unequip:Play()
Idle:Stop() --stop that did not work
Sheathe.Blade.Unsheathe:Play()
wait(0.5)
Sheathe.Blade.Transparency = 0
if Player.Character:FindFirstChild("Equipped") then
Player.Character.Equipped:Destroy()
end
Sheathe.Blade.Unsheathe:Stop()
end)
end)

4 comments
Oh I see my problems now, thank you for the help. I didn't really did that much research on disconnecting functions
Actually I am having one more problem now, the whole thing completely stops, what can I do about that? Like whenever I unequip the tool the idle won't play again when I re-equip it
Im sorry I forgot when you disconnect an event it doesnt set that variable to nil, so the script wont refire. Simply type isrunning = nil underneath isrunning:Disconnect()
Alright thank you