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:
script.Parent.DamagePart.Touched:Connect(function(p) if script.Parent.CanDamage.Value == true then script.Parent.CanDamage.Value = false p.Parent.Humanoid:TakeDamage(10) wait(0.8) script.Parent.CanDamage.Value = true end end)
My LocalScript:
local CanAttack = true script.Parent.Equipped:Connect(function() local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) Idle:Play() end) script.Parent.Activated:Connect(function() local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) if CanAttack == true then Slash:Play() Idle:Stop() CanAttack = false wait(0.8) Slash:Stop() Idle:Play() CanAttack = true script.Parent.CanDamage.Value = true end end)
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.
local CanAttack = true local AttackCounter = 0 script.Parent.Equipped:Connect(function() local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) Idle:Play() end) script.Parent.Activated:Connect(function() AttackCounter = AttackCounter + 1 if CanAttack == true and AttackCounter == 2 then local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle) local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash) AttackCounter = 0 Slash:Play() Idle:Stop() CanAttack = false wait(0.8) Slash:Stop() Idle:Play() CanAttack = true script.Parent.CanDamage.Value = true end end)