The title shows my issue, any help would be great, thanks!
01 | Mouse.Button 1 Up:Connect( function () |
02 | if not AnimationDebounce then |
03 | if game.Players.LocalPlayer.Character:FindFirstChildOfClass( "Tool" ) and script.Parent.BoolValue.Value = = true and Equip = = true then |
04 | if script.Parent:FindFirstChild( "SelectionBox" ) then |
05 | script.Parent.SelectionBox:Destroy() |
06 | end |
07 | local Tool = script.Parent |
08 | if Tool.Parent = = game.Players.LocalPlayer.Character then |
09 | if Tool:FindFirstChild( "DrinkPart" ) then |
10 | AnimationDebounce = true |
11 | if game.Players.LocalPlayer.Character:FindFirstChild( "Torso" ) then |
12 | if Equip = = true then |
13 | script.Parent.RemoteEvent:FireServer() |
14 | Animation:Play() |
15 | wait( 3 ) |
If the animations weren't made by you or Roblox, they will not show up. But the reason this is not working is because the code you're using is highly inefficient.
Add a bool value inside of the tool called "cooldown" and set the value to false.
Possible fix:
01 | local tool = script.Parent |
02 | local animation = script.Animation |
03 | local cooldown = script.Parent.Cooldown |
04 |
05 | tool.Equipped:Connect( function () |
06 | wait( 1 ) -- Waits to prevent lag |
07 | local humanoid = tool.Parent:FindFirstChildWhichIsA( 'Humanoid' ) |
08 | if humanoid and cooldown = = false then |
09 | cooldown = true |
10 | local playanim = humanoid:LoadAnimation(animation) |
11 | playanim:Play() |
12 | tool.Handle.Damage.Disabled = false |
13 | wait( 0.7 ) |
14 | playanim:Stop() |
15 | tool.Handle.Damage.Disabled = true |
16 | wait( 0.5 ) |
17 | cooldown = false |
18 | end |
19 | end ) |