Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a hitbox with humanoids?

Hi, not sure if this is exactly Lua related, but I was curious on how you could make a hitbox that is attached to the humanoid. For example, let's say the hitbox touches a block that would reduce the health by 10. The humanoid's health would be reduced by 10 as well. How would I do that?

2 comments

0

just make whatever is doing damage detect if a part is (just an example) named "hitbox" or something

0

^ technically, the HumanoidRootPart is the main hitbox of the humanoid and cannot be enlarged without the entire rig being enlarged, so you can just attach another part to the root part and use that part as a hitbox

1 answer

✓ Accepted answer

If you want it to hit a body part, try putting this in the part.

local BodyPart = "BODYPARTNAME"--Torso,LeftLeg,etc
script.Parent.Touched:Connect(function(hit)
	if hit.Name == BodyPart then
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		humanoid:TakeDamage(20)
	end
end

Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.