Help with knockback

Hello fellow developers, I’m trying to make an attack move where you pretty much create a huge sphere vfx that grows out and does damage and knockback, the damage is not an issue but the knockback is. An example would be I’m standing in the middle of a bunch of people facing the same direction, when I use the move I want them to be knocked back from the point they got hit on, like if the player is facing straight forward but the part of the vfx that hit them was facing was facing at a 45 degree angle, they would be hit back 45 degrees, the problem is theres not a specific cframe for each small part of the vfx so I don’t know how to do this, any suggestions?

2 Likes

well i assume the player is in middle of the sphere, in that case then all you need to do is just make the players face the one who triggered the attack, if not then make an middle part and make player’s cframe face the part

But I’m pretty sure that will just make everyone get knocked back in the same direction, I’m trying to make the victim(s) be knocked back from not the way they were facing, but which side they got hit from.

no? because the part is in the center, everyone around it will face it.


heres’s a picture of what i mean, the rectangles are players, and they will not face the same direction because their positions are different, therefore facing the part will be in different angle, which is where they got hit

You can use a explosion, configuring the BlastPressure property to knockback the player.
If you want to place the effect of the default explosion, you will need to set it’s position to a part using Explosion.Position.

This should help

local ObjectThatPushes = Sphere -- // Add the object that will PUSH, example > script.Parent  < this will be the Object that script is parented to.

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = Victim -- // Parent it to object you want to push
BodyVelocity.MaxForce = Vector3.new(2500, 2500, 2500)

BodyVelocity.Velocity = -(ObjectThatPushes.Position - Victim.Position).Unit * 45 -- // the * 45 is POWER, so you can change it 

game:GetService("Debris"):AddItem(BodyVelocity, .5)

-- // If it doesn't works correctly, then do this > BodyVelocity.Velocity = -(Victim.Position - ObjectThatPushes.Position).Unit * 45
1 Like

Thank you so much, it worked just like I was going for! But do you know anywhere I could learn more about “Unit” since it seems very helpful.

1 Like

Your welcome, goodluck on your developing!

I recommend to check out: Vector3 , CFrame

Hey, sorry for the bump. I have the same problem as the creator of this topic. The only problem is the velocity calculation. You see, your velocity works, however the further you are from the world center, aka Vector3.new(0,0,0), the more the velocity is. This is really weird, because if you’re at the corner of the map, the velocity would be crazily huge. What’s the way of fixing it?

1 Like

Sorry for not responding, wasn’t on this site for so long. But try to change

BodyVelocity.MaxForce = Vector3.new(2500, 2500, 2500)

if that works else I don’t know probably sorry. I will try finding solution if its not solved yet

Hey, I found out that I had some issues with my scripts, your solution works well! Thank you for your time

1 Like