Why won't this Body Velocity script work?

Hello,
I have a script (I’ll put it below.) that knocks a player back when they touch a part.

But it doesn’t move the player at all, nor effect them.

local BV = Instance.new("BodyVelocity", PlrToKnockback)
BV.maxForce = Vector3.new(25000,25000,25000)
BV.Velocity = EnemyChar.HumanoidRootPart.CFrame.lookVector*100
game.Debris:AddItem(BV,0.5)
BV.Velocity = BV.Velocity + Vector3.new(0,2,0)

PlrtoKnockback is the enemy player im trying to knock the opposite way to EnemyChar.

Thanks!

1 Like

I can’t figure this out, any help would be great!

1 Like

hmm, Is PlrToKnockback a player instance, because then bodyVelocity will not work. It should be a basepart such as as the player’s hrp. I believe you use a touched event, so I assume your code snippet is just the body Velocity.

local Part = script.Parent 
local EnemyChar = ... 

Part.Touched:Connect(function(hit)
	local HRP = hit.Parent:FindFirstChild("HumanoidRootPart")
	if HRP then
        local PlrToKnockback = hrp
		local BV = Instance.new("BodyVelocity", PlrToKnockback) 
		BV.MaxForce = Vector3.new(25000, 25000, 25000)
		BV.Velocity = EnemyChar.HumanoidRootPart.CFrame.lookVector * 100 
		game:GetService("Debris"):AddItem(BV, .5) 
	end
end)

So I think if figured out the problem it’s the Parent it should be in the enemy’s hrp and also if you want them to take Knick back the easier way is ehrp.CFrame.LookVector * -100 or maybe -ehrp.CFrame.LookVector * 100 and ehrp is enemy humanoid root part.

Nevermind, I wrote something stupid (edit)