Hello, yes I asked the question 3 times. But I still dont know where I should put a double click function, and i dont know how I should make my double click function! Help?
My script for attacking:
1 | script.Parent.DamagePart.Touched:Connect( function (p) |
2 | if script.Parent.CanDamage.Value = = true then |
3 | script.Parent.CanDamage.Value = false |
4 | p.Parent.Humanoid:TakeDamage( 10 ) |
5 | wait( 0.8 ) |
6 | script.Parent.CanDamage.Value = true |
7 | end |
8 | end ) |
My LocalScript:
01 | local CanAttack = true |
02 |
03 | script.Parent.Equipped:Connect( function () |
04 | local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) |
05 | local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) |
06 |
07 | Idle:Play() |
08 | end ) |
09 |
10 | script.Parent.Activated:Connect( function () |
11 | local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) |
12 | local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) |
13 |
14 | if CanAttack = = true then |
15 | Slash:Play() |
To make a double click function, you have to check if Activated is fired twice in a certain period of time. Use a variable to track how many times Activated has been fired and if its at least 2 within lets say 0.35 seconds, then run the function. If you need any help, feel free to reply to my answer.
Add a counter to tell how many times you activated it or clicked. The guy above me said the same thing I just wanted to show you what that would look like.
01 | local CanAttack = true |
02 | local AttackCounter = 0 |
03 |
04 | script.Parent.Equipped:Connect( function () |
05 | local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) |
06 | local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) |
07 |
08 | Idle:Play() |
09 | end ) |
10 |
11 | script.Parent.Activated:Connect( function () |
12 | AttackCounter = AttackCounter + 1 |
13 | if CanAttack = = true and AttackCounter = = 2 then |
14 | local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) |
15 | local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) |