Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a script end when a tool is equipped by the player?

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

1 answer

✓ Accepted answer

You could disable the script?

2 comments

0

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.

0

Then make them seperate scripts

This discussion is preserved as it was. New answers, comments, and votes are closed.