How would I go about making my hitbox hit stuff

I’m quite new to Lua and to Roblox Studio, however I’ve been working on a basic combat system for a game and I’ve reached the point where I can generate a hitbox in front of the player using this:

		local hitbox = repStore.CharTest001.M1hitboxT001:Clone()
		hitbox.Parent = workspace
		hitbox.CFrame = player.Character.HumanoidRootPart.CFrame + player.Character.HumanoidRootPart.CFrame.LookVector * 3
		local connectHitboxWeld =Instance.new("WeldConstraint")
		connectHitboxWeld.Parent = player.Character
		connectHitboxWeld.Part0 = player.Character.HumanoidRootPart
		connectHitboxWeld.Part1 = hitbox

I’ve looked around the forum a bit but I haven’t yet found a solution which is clear, but what I’m aiming to do is make any “Enemy” model touching this take some damage. Any advice?

1 Like

There’s three main options you can pick when making hitboxes:

  1. Magnitude: Magnitude checks are done by checking the distance between the origin of the hitbox and the potential targets, resulting in a sphere-like shape. They’re very simple and I would reccomend using them if you don’t need hitboxes in a specific shape.
  2. GetPartBoundsInBox: Bounds box checks are more like you’d see in a 2D fighting game. They use a CFrame and Size to return all intersecting parts. If you need attacks to be precise about where they hit, this is the way to go.
  3. Raycasts: Raycasts are only really used for super-precise hitboxes, like if you’re trying to replicate Morhau’s combat. The main problem is that since the hitbox is determined by the animation, you will need to change the animation if you want to change the hitbox’s trajectory.
2 Likes

Hi Randomness!! I wrote a quick, simple script that should more or less do what you want. Let me know if you have any questions!

local hitbox = repStore.CharTest001.M1hitboxT001:Clone()
local damage = --// whatever number of damage you want to do per hit

hitbox.Touched:Connect(function(Part)
  if Part.Parent.Name == "Enemy" then
    Part.Parent.Humanoid.Health -= damage
  end
end)

How could someone use raycast to make a punch combat with m1 strings? I use raycast for impact skills and Raycast Hitbox 4.01 for melee weapons.

I think you can put the hitbox attachments in the arms, but if that doesn’t work, you can weld parts to the hands containing the attachments.

1 Like