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