local attackCooldown = 1 local attackWindup = 0.5 local attackRange = 3 local attackDamage = 20
local char = script.Parent.Parent local hum = char:WaitForChild("humanoid") local originalWalkSpeed = hum.WalkSpeed
local canAttack = true
script.Parent.AttackRemote.Event:Connect(function(plrRoot)
if not canAttack then return end canAttack = false hun.Walkspeed = 0.1 local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://7209529782" local playAnim = hum:LoadAnimation(anim) playAnim:Play() wait(attackWindup) local newDistance = (char.HumanoidRootPart.Position - -plrRoot.Position).magnitude if newDistance <= attackRange + 5 then if plrRoot.parent.Player.isBlocking.Value == true then attackDamage *= 0.5 end plrRoot.Parent.Humanoid:takeDamage(attackDamage) wait(attackCooldown) hum.WalkSpeen = orininalWalkSpeed canAttack = true end end)
Marked as Duplicate by appxritixn
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?