I there so i need some help with a kind of a double click function. When the player clicks once the sword will slash or just normal swing and for the double click the sword will turn 90 degrees and hit the player. Does anyone know what I should do Thanks!

Here is 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(20)
	wait(1)
	script.Parent.CanDamage.Value = true
	end
end)

My Local script for animations:

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(1)
		Slash:Stop()
		Idle:Play()
		CanAttack = true
		script.Parent.CanDamage.Value = true
	end
end)

I want the function to happen in the script for Attacking. Advice is all taken, Thanks!

2 comments

0

I know this is vague but try implementing Tick() in your script. Tick is the amount of time that passed from a certain date (I think 2006). Put Tick() Value in a variable at the start of the script and when the player clicks, check how much time passed but subtracting Tick() with the Tick() you had stored. Hope this helped

0

^ It's 1970, actually. "The Unix epoch is the time 00:00:00 UTC on 1 January 1970."