How to send player backwards from current position using BodyPosition

I’m trying to create a knock back system in a tool atm using BodyPosition, as I find bodyvelocity to be very inconsistent. Could someone help me understand what kind of equation I would use to send the player hit (for example) 10 studs back from the caster? Here’s the code I have now


KickRay.OnHit:Connect(function(hit, humanoid)
        local enemyRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
        local casterRoot = character:FindFirstChild("HumanoidRootPart")
        local BodyPos = Instance.new("BodyPosition")
        BodyPos.MaxForce = Vector3.new(999999,999999,999999)
        BodyPos.Position = Vector3.new(enemyRoot.Position) + Vector3.new(0,0,10)
        BodyPos.Parent = enemyRoot
        debris:AddItem(BodyPos, 1)

BodyPos.Position = casterRoot.Position + ((casterRoot.Position - enemyRoot.Position).Unit * 100)
Change 100 to the force you’d like the knockback to be.

1 Like

Thank you! I assumed it would be something involving casterroot-enemyroot but I wasnt sure on the rest of it, appreciate it

1 Like