-- R attack
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")
local AnimationID = 'rbxassetid://4868889544'
local key = 'R'
local debounce = true
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
debounce = false
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
LoadAnimation:play()
wait(5)
debounce = true
end
end)
This is the local script in my tool and it plays animation when I press "R", but it still plays animation after too is unequipped, how to fix that? I tried using Tool.equipped event, but I failed and messed up the whole script, my scripting skills are very low.
