How to execute something if a tool isnt found in the backpack

Hey,

I want that if the tool is unequipped or removed from the backpack the animation ends.
I tried it that way:
if Character.Backpack:FindFirstChild(“Wheelbarrow”) == nil or Character.Character:FindFirstChild(“Wheelbarrow”) == nilthen
LoadedAnim:Stop()
end
Is that right? Because it doesn’t work.

tool.AncestryChanged:Connect(function(Old, New)
    if New.Name == "Backpack" then
        animation:Stop()
    end
end)


I just made this now, but it doesn’t work. The animation doesn’t stop.

oh wait, Tool.Unequipped works, try that instead.

If I do that, the animation isn’t playing anymore.

that’s what you wanted to achieve, correct?

Sorry, I meant if I do that, the animation is never playing, not even if you equip the tool.

try to load the animation once, because loading the animations every time would break things

1 Like

Do I load it mutliple times? Where?

tool.Equipped
...
LoadAnimation
...

What do you mean by that? Sorry :smiley: Im not a scripter, could you maybe change the script to how it should work?

1 Like

local Tool = script.Parent
local R15 = script:WaitForChild(“R15”, 1) – Skript finden R15 Animation
local R6 = script:WaitForChild(“R6”, 1) – Skript finden R6 Animation

– Voreinstellungen für Skriptwerkzeuge

Tool.Equipped:Connect(function()
local Character = Tool.Parent
if Character then
local Humanoid = Character:FindFirstChildWhichIsA(“Humanoid”)
if Humanoid then
local LoadedAnim = nil
if Humanoid.RigType == Enum.HumanoidRigType.R15 and R15 then
LoadedAnim = Humanoid:LoadAnimation(R15)
elseif Humanoid.RigType == Enum.HumanoidRigType.R6 and R6 then
LoadedAnim = Humanoid:LoadAnimation(R6)
end
if LoadedAnim then
LoadedAnim:Play()
end

		if Tool.Unequipped then
			LoadedAnim:Stop()
					
				end
	end
end

end)

Thats the script, what should I change?