BodyVelocity Doesnt Launch NPC

So currently, I am trying to add a system to where if a humanoid is in range of my hitbox, a velocity is added and the NPC gets launched. The issue here is the body velocity does nothing to the npc. Here is the code.

local function HitBoxHandler(func)
	local Touching = GetTouchingParts(Hitbox)
	local Characters= {}
	for i, v in pairs(Touching) do
		if not table.find(Characters, Touching[i].Parent) and Touching[i].Parent:FindFirstChild('Humanoid') and not Touching[i]:FindFirstAncestor(script.Parent.Name) then
			table.insert(Characters, Touching[i].Parent)
		end
	end
	
	for i, v in pairs(Characters) do
		func(v)
	end
end

local function TakeDamage(Character)
	Character.Humanoid:TakeDamage(6)
	
	local bv = Instance.new("BodyVelocity")
	bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bv.Velocity = script.Parent.HumanoidRootPart.CFrame.LookVector * 50
	bv.Parent = Character.HumanoidRootPart
	
	Debris:AddItem(bv, 0.2)
end

local function OnPunch(Player)
	local Character = Player.Character
	HitBoxHandler(TakeDamage)
end

StrongPunchEvent.OnServerEvent:Connect(OnPunch)

The Humanoid still takes damage and the BodyVelocity is still parented to the humanoidrootpart

1 Like

I think the problem is that it isn’t so easy to move humanoids when they’re on the ground. Maybe try moving the NPC upwards a tiny bit when parenting the BodyVelocity.

Character.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame + Vector3.new(0, 2, 0) -- moved a bit upwards
bv.Parent = Character.HumanoidRootPart
1 Like

Just realized the NPC was anchored… thanks lol

1 Like

Don’t forget to mark a post as the solution (can be your own).

1 Like