How do I add debounce to an animation script?
Asked by
5 years ago Edited 5 years ago
I've got a script that randomly picks one out of three animations when the player clicks, and I've tried to add debounce to it. Here's the product:
03 | local UserInputService = game:GetService( "UserInputService" ) |
04 | local Player = game.Players.LocalPlayer |
05 | local Character = Player.Character |
06 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
07 | UserInputService.InputBegan:Connect( function (InputObject) |
08 | if InputObject.UserInputType = = Enum.UserInputType.MouseButton 1 then |
10 | local numberofanims = 3 |
11 | local num = math.random( 1 ,numberofanims) |
13 | local Animation = Instance.new( "Animation" ) |
15 | local Track = Humanoid:LoadAnimation(Animation) |
19 | local Animation = Instance.new( "Animation" ) |
21 | local Track = Humanoid:LoadAnimation(Animation) |
25 | local Animation = Instance.new( "Animation" ) |
27 | local Track = Humanoid:LoadAnimation(Animation) |
The problem is, the debounce has no effect. The player can still spam click their mouse and the animations are cut off. Please tell me what I did wrong.