Creating a Hitbox system

hello, i am making a game with npcs that fight eachother. I would like to make a very simple hitbox system (no raycasting or anything) for my game. could anyone walk me through on how to make one that isn’t hard to use?

very simple method is you can use is by making a part, connected to a touched event with a debounce script and then weld that to the users hrp and delete it after a short period of time.

	local hitbox = Instance.new("Part", game.Workspace)
	hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -2)
	hitbox.CanCollide = false
	hitbox.Massless = true
	hitbox.Size = Vector3.new(5,5,4)
	hitbox.Anchored = false
	hitbox.Transparency = 1
	Debris:AddItem(hitbox, 0.35)

	local weld = Instance.new("Weld")

	weld.Part0 = plr.Character.HumanoidRootPart
	weld.C0 = plr.Character.HumanoidRootPart.CFrame:Inverse()
	weld.Part1 = hitbox
	weld.C1 = hitbox.CFrame:Inverse()

	weld.Parent = hitbox

very old script of mine, but connecting the hitbox to a touchedevent will work.

you can also use magnitude for combat, bit advanced but works very well.


this checks in front of the user. and not completely 360. you can have it check completely around you if you remove the dot and scale stuff.

2 Likes

there are still easier methods for this, but you should do magnitude combat as it works best for it’s simplicity and less code.

the first set of code was from a very long time ago and probably has alot of wrongs in it but i hope it helped.

2 Likes

this is cool but for my game i am looking for a module script hit box system

that’s what i gave you, you can add that code to a module script and expand it yourself

1 Like