Why does the onhit never register

local char = script.Parent.Parent.Parent
repeat wait() until char.Parent == workspace
local HitForce = 40
local d = false
local hitd
local smacker = script.Parent.smacker
local Tool = script.Parent
local RaycastHitbox = require(game:GetService(“ReplicatedStorage”).RayTracing)
local Hitbox = RaycastHitbox:Initialize(char, {char})
Hitbox:PartMode(true)

script.Parent.clickevent.Event:Connect(function(pos)
if d == false then
local BV = Instance.new(“BodyVelocity”, char.RightHand)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = (char.HumanoidRootPart.Position - pos).Unit * -75
smacker.Trail.Enabled = true
d = true
smacker.Swoosh:Play()
print(“before onhitfunction”)

Hitbox.OnHit:Connect(function(hit)
print(“onhitfuntion started”)
if hit and hit.Parent ~= char then
hitd = true
local root = hit.Parent:FindFirstChild(“HumanoidRootPart”)
local delta = root.Position - pos
hit.Parent:FindFirstChild(“owie”):FireAllClients()
local bv = Instance.new(“BodyVelocity”)
bv.maxForce = Vector3.new(1e9, 1e9, 1e9)
bv.velocity = delta.unit * HitForce
bv.Parent = root
game:GetService(“Debris”):AddItem(bv, 0.05)
smacker.Smack:Play()
print(“onhitfunction ended”)
end
end)

print(“after onhit func”)
game.Debris:AddItem(BV, 0.1)
wait(0.1)
Hitbox:HitStop()
smacker.Trail.Enabled = false
wait(0.5)
d = false
end
end)

Here is my code, still not sure why it isn’t ever registering

Please format your code properly using code blocks + indent your code:
```
code
```
Most won’t bother to help if they can’t read the code easily.

local char = script.Parent.Parent.Parent
repeat wait() until char.Parent == workspace

local HitForce = 40
local d = false
local hitd
local smacker = script.Parent.smacker
local Tool = script.Parent
local RaycastHitbox = require(game:GetService(“ReplicatedStorage”).RayTracing)
local Hitbox = RaycastHitbox:Initialize(char, {char})
Hitbox:PartMode(true)

script.Parent.clickevent.Event:Connect(function(pos)
if d == false then
local BV = Instance.new(“BodyVelocity”, char.RightHand)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = (char.HumanoidRootPart.Position - pos).Unit * -75
smacker.Trail.Enabled = true
d = true
smacker.Swoosh:Play()
print(“before onhitfunction”)

Hitbox.OnHit:Connect(function(hit)
print(“onhitfuntion started”)
if hit and hit.Parent ~= char then
hitd = true
local root = hit.Parent:FindFirstChild(“HumanoidRootPart”)
local delta = root.Position - pos
hit.Parent:FindFirstChild(“owie”):FireAllClients()
local bv = Instance.new(“BodyVelocity”)
bv.maxForce = Vector3.new(1e9, 1e9, 1e9)
bv.velocity = delta.unit * HitForce
bv.Parent = root
game:GetService(“Debris”):AddItem(bv, 0.05)
smacker.Smack:Play()
print(“onhitfunction ended”)
end
end)

print(“after onhit func”)
game.Debris:AddItem(BV, 0.1)
wait(0.1)
Hitbox:HitStop()
smacker.Trail.Enabled = false
wait(0.5)
d = false
end
end)

sorry about that

physics_test (1).rbxl (140.0 KB)
you can use this to debug it
also press q to equip the weapon