Knockback always moves the dummy to the same direction

Awesome module script. You’re going in the right direction with all this, so let’s make some changes.

In your module script, we will create a BodyVelocity every time your character hits the target.

So we will make:

function Knockback.createVelocity()
	local bv = Instance.new("BodyVelocity");
	bv.P = 1250;
	local max = 75000;
	bv.MaxForce = Vector3.new(max, max, max);
	return bv;
end

So now we have our BodyVelocity. Next, we’ll apply our knockback with the direction that we are looking at:

local Debris = game:GetService("Debris");

function knockback.applyKnockback(hrp, targetHRP, power, duration)
	
	if hrp and targetHRP then
		local bv = knockback.createVelocity()

		local direction = (hrp.Position - targetHRP.Position).Unit
		bv.Velocity = -direction * power
		
		bv.Parent = targetHRP

		Debris:AddItem(bv, duration)
	end
end

Try this out and see if it works for you.

2 Likes

Are the hitboxes parented to the Roblox character? If so you can do this.

Hitbox’s parent = Attacking Character
Hit’s parent = Character that’s receiving attacks

HitModule.Knockback(Hitbox.Parent, Hit.Parent, 10) – Just put 10 as a test

1 Like

Oh my god, after 5 hours you finally got it to work. Thank you so much you’re a life saver!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.