The knockback is applied too fast and I don't know how t fix it. Whenever the 4th punch hits, it applies knockback, instead of the 5th.
debounce = false combo = 1
script.Parent.OnServerEvent:Connect(function(player, action) local character = player.Character if debounce then return end
if action == "combat" then
debounce = true
if combo == 1 then
combo = 2
local rightPunch = character.Humanoid:LoadAnimation(script.rightPunch)
rightPunch:Play()
elseif combo == 2 then
combo = 3
local leftPunch = character.Humanoid:LoadAnimation(script.leftPunch)
leftPunch:Play()
elseif combo == 3 then
combo = 4
local rightUppercut = character.Humanoid:LoadAnimation(script.rightUppercut)
rightUppercut:Play()
elseif combo == 4 then
combo = 5
local leftUppercut = character.Humanoid:LoadAnimation(script.leftUppercut)
leftUppercut:Play()
elseif combo == 5 then
combo = 1
local spinKick = character.Humanoid:LoadAnimation(script.spinKick)
spinKick:Play()
end
wait(0.2)
local ray = Ray.new(character.HumanoidRootPart.Position, character.HumanoidRootPart.CFrame.lookVector * 8)
local calcRay = workspace:FindPartOnRay(ray, character)
if calcRay then
if calcRay.Parent:FindFirstChild("Humanoid") and calcRay.Parent ~= character then
calcRay.Parent.Humanoid:TakeDamage(5)
local hitSound = script.hitSound:Clone()
hitSound.Parent = calcRay
hitSound:Play()
if combo == 5 then
local bodyVelocity = Instance.new("BodyVelocity", calcRay)
bodyVelocity.MaxForce = Vector3.new(25000, 25000, 25000)
bodyVelocity.Velocity = character.HumanoidRootPart.CFrame.lookVector * 20
game.Debris:AddItem(bodyVelocity, 0.3)
end
end
end
wait(0.25)
debounce = false
end
end)

2 comments
So what should I do?
Nevermind I figured it out.