So I have a keybind script that I am using to toggle an animation in game when a certain key is pressed. It is working, however, I want the keybinds not to toggle if the player has a tool equipped. There are multiple tools in the game which is why I can't just specify one tool. I am not sure how to go about doing this though. This is the code:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local CharAnimation
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
animation("5102197274")
elseif inputObject.KeyCode == Enum.KeyCode.Q and not gameProcessedEvent then
animation("5102987158")
end
end)
function animation(AnimationID)
if Character then
local UseLessAnimation = Character:FindFirstChild("AnimationCharacter")
if CharAnimation then
CharAnimation:Stop()
end
if UseLessAnimation then
if UseLessAnimation.AnimationId == "rbxassetid://"..AnimationID then
UseLessAnimation:Destroy()
return
end
UseLessAnimation:Destroy()
end
local Animation =Instance.new("Animation",Character)
Animation.Name= "AnimationCharacter"
Animation.AnimationId = "rbxassetid://"..AnimationID
CharAnimation= Character.Humanoid:LoadAnimation(Animation)
CharAnimation:Play()
end
end

2 comments
The thing is the script needs to be able to keep running once the weapon is put away because this is an at-ease and salute script.
Then make them seperate scripts