Keybind Animation Problem

I have a keybind animation script, where when you press ‘E’ a salute animation plays. How would I disable this script if a player equipped a tool? I also have avacore, where if you press E you salute or patrol mode.

Script:

local service = game:GetService('UserInputService')
local B = 'F'
local animation, AnimationPlaying = nil, false
local humanoid = script.Parent:WaitForChild("Humanoid")
local animation = humanoid:LoadAnimation(script:WaitForChild("Animation"))
local plr = game.Players.LocalPlayer


service.InputBegan:Connect(function(Input, UI_Interacting, Tool_Interacting)
	if plr:GetRankInGroup(9536284) >= 1 then
		if Input.KeyCode == Enum.KeyCode[B] then
			if AnimationPlaying then
				animation:Stop() 
			else
				if UI_Interacting then return end
				AnimationPlaying = true
				animation:Play()
				animation.Stopped:Wait()
				AnimationPlaying = false

				if Tool_Interacting then return end
					AnimationPlaying = false
					
				
			end
		end
	end
end)```

You can add a condition before playing the animation.

local Char = plr.Character --Defines Character
if Char then --Checks for Character
	if not Char:FindFirstChildOfClass("Tool") then --If the character does not have a tool then
		--DoStuffHere
1 Like