Raycast Hitbox 4.01: For all your melee needs!

Nope. You’ll notice that part of the module’s API is to start and stop a hit cycle. Just create one hitbox around the player’s hands. When they start punching, use the start method so that it can start capturing targets and performing hit actions (e.g. damage). When the punch should be ending, use the stop method.

2 Likes

I tried do that but when I dont deinitialize the hitbox stop working for some reason.

1 Like

Perhaps that’s something you’d like to create a support request for or take up privately after a bit of debugging then, the latter case being that you could potentially be wrongly using the module and resulting in errors or are running into limitations.

Can I send my code here? Soo I can know if I’m using the module wrongly

1 Like

I mean, sure, feel free to do so. You don’t need to ask me and I didn’t create this thread, I’m just someone who lurks here frequently.

1 Like

my code:

		local DmgPoints = RS.Specials.DmgPointsArms:GetChildren()
		for i = 1, #DmgPoints do
            local v = DmgPoints[i]
			local DmgPointClone = v:Clone()
            DmgPointClone.Parent = Character["Right Arm"]
		end
			
		local Animation = Instance.new("Animation")
		Animation.AnimationId = "rbxassetid://ANIMATIONID"
		local PunchAnimation = Character.Humanoid:LoadAnimation(Animation)

local Hitbox = RaycastHitbox:Initialize(Character, {Character})
Hitbox.OnHit:Connect(function(hit, humanoid)
--some stuff here
end)
		PunchAnimation:GetMarkerReachedSignal("StartDamaging"):Connect(function()
Hitbox:HitStart()
end)
		
		PunchAnimation:GetMarkerReachedSignal("StopDamaging"):Connect(function()
Hitbox:HitStop()
end)

		PunchAnimation.Stopped:Connect(function()
			Animation:Destroy()
			Animation2:Destroy()
			local CoroutineThread = coroutine.wrap(function()
			RaycastHitbox:Deinitialize(Character)
		    local DmgPoints = Character["Right Arm"]:GetChildren()
		    for i = 1, #DmgPoints do
                 local v = DmgPoints[i]
			     if v:IsA("Attachment") and v.Name == "DmgPoint" then
				     v:Destroy()
			     end
		    end
			end)
			CoroutineThread()
		end)

2 Likes

So I’ve tried working with this code in Studio and I can’t seem to find any issues. I’m not sure what issue you’re experiencing exactly here but for me, it’s seemed to have worked fine.

If you’re unable to discern a point of error, consider any of these three options:

  • Debug your code so that you can isolate the issue and resolve it.

    • Be sure to make use of the console. This module prints for various actions and you can do so as well.
  • Rework your code a bit and remake your punch tool from the ground up.

  • Consider creating a Scripting Support topic with the given resource, a repro file and remember to follow in the spirit of the category wrt the guidelines. They may be able to help you as well.

    • Quick issues with the module are fine to be taken up on a resource thread directly, but for longer issues that may not see any quick resolution, it’s worth creating a separate topic or reconvening with the resource author in private.
2 Likes

Hi i am on mobile so pardon if i missed anything but, may i ask why you are deleting the dmgpoints? Unless the animation is only played once ever, that maybe the cause of issue.

2 Likes

The animation should play everytime the player click at mouse, I think that can be the cause of the problem (lag)

4 Likes

I’m not using a tool, I’m adding attachments to player arm’s and it works fine, I was getting some lag in my game soo I think it might be because I’m creating a hitbox everytime player click at the mouse button.

2 Likes

Hey do you have a discord I can message you on? I would like to talk to you about further uses and current issues I’m experiencing.

2 Likes

Why not use this thread for that? It’s a perfect place to put brief issues and other use cases. This is also a public resource so your use cases or information may be able to help others, unless it’s for a confidential project you aren’t comfortable sharing details from.

6 Likes

Sorry it’s nothing like that, I just wanted a more comfortable place to talk and then I was planning to relay my information back to here in an organised manner.

1 Like

@TeamSwordphin,

Do you recommend this to be used on the Server or Client?

How to they compare and what are the differences other than Client-side would be smoother and better for UX but less secure;

How can we address in the best way possible to suit this module?

Is it designed to be used on the Client or Sever

3 Likes

It is honestly personal preference. This module was designed to be server sided at first (and I personally use it server sided cause my enemies use it) but if you require tight feedback such as PvP scenarios, client side might be a better option. As long as you do common sense checks, it can be secure as leaving it server sided (it just will need more work). Server side only has the downside of a little more latency. You will not be able to use the included damage function if you put it client sided, but most people don’t anyway. There is not much difference other than that.

You can also utilize this module both ways, having the client draw the hitboxes to ask if they can damage this target, and the server also drawing the hitboxes, making sure the client has accurately hit the right target. Putting it on the client helps you draw responsive visuals while also retaining accuracy that the server can then verify. I made this module in a way where people can adapt it to whatever scenario they please. Just go about it the same way you would approach any other hit detection system.

3 Likes

Is it accurate UX wise when implement both Server and Client Hit detection?

It’s terrible if the player sees that they hit a target but it doesn’t register.

What kind of checks do you recommend?

1 Like

Yea, if you are going to have both server/client simultaneous detection, you will need to make some sort of ping compensation. Alternative ways you can verify the hit is true from the client is angle checks. If the move is supposed to be a stab but you are getting damaged behind, that is a red flag. Moreover, A sword shouldn’t be able to hit a target 50 studs away. Raycast between your targets so they aren’t hitting each other through walls, etc. Use common sense in making server checks. Depending on what type of fighting game you are making, these server checks will vary heavily depending on your needs. There really isn’t one check that fits all games so you will have to do a bit of creative testing here.

PvP focused games usually favor the client, but some games do a hybrid system where lower pinged players will have their hit detection done on the client and simply sent to the server with verification and higher pinged players will have their hit detection on the server.

3 Likes

This is really nice. Will definitely use this!

2 Likes

So, I really liked this module and I pre-set attachments on tools for raycast hitboxing, however, I was stumbled on if you could or how to create those DmgPoint attachments via scripting? For example, if I wanted to create raycast hitboxing on a player’s fist, how would I do it? I was generally confused with a lot of the documentation inside the module.

1 Like

There are two ways to do this. The foolproof way is to just instance a new attachment object, rename it, and adjust its worldposition in your characters fist. After, call initialize (or Deinitialize first if you already initialized prior to attachment instancing). The module should automatically fetch it.

The second, slightly more advanced but preferable way if you are scripting dynamic dmg points are using the :SetPoints function. I had an example code somewhere in this thread where you can search for. This is good because you can make new points of raycast without deinitizializing your created hitboxes as it caches immediately upon calling the function. It also is probably more performance friendly too since it’s all vector based without the hassle of performance costs from instancing.

5 Likes