What am i doing wrong in this animation script? *REPOSTED AND UNSOLVED*
Asked by
6 years ago Edited 6 years ago
I'm trying to make a script for a tool where pressing the X button would only play the animation if my tool was equipped. Problem is, when i unequipped the tool i can continue to press x again and the animation would still play.
02 | local UIS = game:GetService( 'UserInputService' ) |
05 | local tool = script.Parent |
06 | local player = game.Players.LocalPlayer |
07 | local char = player.Character |
10 | player.CharacterAdded:Connect( function (character) |
12 | local hum = char:WaitForChild( 'Humanoid' ) |
15 | local spinSlash = hum:LoadAnimation(tool.Animation) |
18 | tool.Equipped:Connect( function () |
22 | UIS.InputBegan:Connect( function (input) |
23 | if input.KeyCode = = Enum.KeyCode.X and not debounce then |
33 | tool.Unequipped:Connect( function () |
Again, i only want the x button to play the animation when the tool is equipped.