https://www.youtube.com/watch?v=7Cf5Olp3tJ0
The Sword was suposed to damage any humanoid that it touches on the first swing but the damage function is being activated with a delay for some reason and it is making it only damage things ontouch after the animation is done.
The Code:
if keyPressed == Enum.KeyCode.Z and Toggled == true and AnimOn == false and ZAttackCD == true then
AnimOn = true
ZAttackCD = false
Humanoid.WalkSpeed = 0
ZAttack:Play()
wait(0.25)
TParts.Trail.Enabled = true
local Conn
Conn = TParts.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not hit.Parent.Humanoid:FindFirstChild("BValue") then
local dtag = BValue:Clone()
dtag.Parent = hit.Parent.Humanoid
hit.Parent.Humanoid:TakeDamage(15)
game:GetService("Debris"):AddItem(dtag,1)
wait(1)
Conn:Disconnect()
end
end
end)
wait(0.85)
TParts.Trail.Enabled = false
ZAttack.Stopped:Wait()
AnimOn = false
Humanoid.WalkSpeed = WalkSpeed
wait(10)
ZAttackCD = true
Summing up:I want to make it so the sword damages while the char plays the animation of the first swing, not after nor before.
Any help would be appreciated, thanks.
