Help with Raycast Hitbox

There’s a module called Raycast Hitbox, and I’m having some trouble with it.
Here’s the module: Raycast Hitbox 4.01: For all your melee needs!
Here’s my script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)

local swordHitbox = RaycastHitbox.new(script.Parent)

swordHitbox.OnHit:Connect(function(hit)
	print("hit")
	local model = hit.Parent
	print(model.Name)
	if model.Name == "Burger" or model.Name == "Taco" then
		if model.ClassName == "Model" then
			local health = model:GetAttribute("Health")
			health = health-100
			model:SetAttribute("Health", health)
		end
	end
end)

while true do
	swordHitbox:HitStart()
	wait(3)
	swordHitbox:HitStop()
	wait(3)
end

My problem is that it doesn’t take away any health from the model. How do I fix this?

You need to write back the changed value with SetAttribute. health only contains a copy of the value you’re trying to change, it doesn’t store the actual location of the Health attribute.

edit: My bad I see that you do in fact do that.

I don’t think the program senses the hitbox getting hit. It never shows “hit” in the output.

Does the module give you any way to visualize the hitbox to make sure its in the right position?

Yes, and it is in the right position.
.

Does it print “hit” at all? Have you tried printing model?

1 Like

No, it doesn’t print hit at all. Do I need to acknowledge the fact that there is no humanoid?

Can you think of anything else I might be doing wrong? I have all this code in a local script in the tool, not the part. After looking at the API, I edited the code a bit too. Here’s the new code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
print("Raycast Hitbox Module Found")

local swordHitbox = RaycastHitbox.new(script.Parent)

print("sword hitbox found")

swordHitbox.OnHit:Connect(function(hit, humanoid)
	print("hit")
	if not humanoid then
		local model = hit.Parent
		print(model.Name)
		local health = model:GetAttribute("Health")
		health = health-100
		model:SetAttribute("Health", health)
		print(health)
	end
end)

script.Parent.Activated:Connect(function()
	swordHitbox:HitStart()
	wait(3)
	swordHitbox:HitStop()
end)

@azqjanna do you see anything wrong with this new script?

@azqjanna or @Ripxff Please respond. This is very urgent.