I inserted this local script in the tool, it doesn't show any errors, but it is not playing animation. why is this happening and how to fix that?
local Tool = game:GetService("StarterPack"):WaitForChild("Excalibur")
local Tool = game:GetService("StarterPack"):FindFirstChild("Excalibur")
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 Animation = Instance.new("Animation")
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
local key = 'R'
local debounce = true
Tool.Equipped:Connect(function() -- If the Tool is equipped
UserInputService.InputBegan:Connect(function(Input, IsTyping) -- If the player presses the key while the Tool is equipped then it will run the code below.
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
debounce = false
LoadAnimation:Play()
wait(3)
debounce = true
end
end)
end)
Tool.Unequipped:Connect(function() -- If the player has unequipped the Tool, we want to stop the animation in case they unequip the Tool during the Animation.
LoadAnimation:Stop()
end)
