Raycast Hitbox 4.01: For all your melee needs!

If possible, can you show any video footage of it happening? If the hitbox is created on the server side, I suspect it may be a Roblox replication bug that is out of the scope of the module (though will need to check to confirm if it is). The only fix that I know of if this is your case is to move the hitbox logic to the client.

Also let me know if you are using attachments and/or setpoints.

1 Like

My computer is too garbage to record video but i can provide examples.

The hitbox is created on the server, and attachments are used for the damage points.

Lets say for example I am using a tool with this implemented, a basic sword. If I set the CFrame of the HumanoidRootPart to turn the charactera certain direction, the hitbox will now be offset at the angle I had set for the player, only in the opposite direction.

Another example is if i set the CFrame of the root to a different position to teleport the character, the hitbox will now be offset the distance that teleport was from where the player was originally.

i made some code to make the attachments on the weps u cn put this in the cmd line to use-

local part = game.Workspace.Tool.Hitbox;
local attachcount = math.floor( part.Size.Y);
	for i= part.Position.Y - part.Size.Y/2, part.Position.Y + part.Size.Y/2,0.5 do
	local currattach = Instance.new("Attachment");
currattach.Name = "DmgPoint";
	currattach.Parent = part;
	currattach.WorldPosition = Vector3.new(currattach.WorldPosition.X,i,currattach.WorldPosition.Z);
end

So even if I were to have hundreds of npcs using a raycast hitbox, the performance would be better than Touched? Is touched fired even if you do not connect to it in the backend?

Need help with serverside raycasting. There always seems to be a delay on the clients side everytime I try to use it.
For reference: https://cdn.discordapp.com/attachments/797876906862182430/823305914424492032/clientvsserver480p.mov (serverside raycasting from the clients perspective)

Also for reference: https://cdn.discordapp.com/attachments/780904700873932870/823213960182235156/test.mov (How other players view it)

You can see that the clients perspective shows a delay (probably because the raycasts are being ran serverside). Is there anyway I can remedy this AND keep the rays serversided?

Unfortunately, this is called latency. The time it takes for the client to send information to the server and then back requires distance, and distance requires time. Roblox replication runs much slower and less frequently than the client’s FPS, meaning there will always be inaccuracy issues compared to making it client-sided, so regardless of what remedies you attempt to make it smoother for the client, it will never be a replacement for pure client-side implementation.

An example of server latency can be seen here in a previous post:

The server will always see changes much, much later than what clients see. This is also why competitive FPS games have trouble in solving their “peeker’s advantage”, as the client user always sees the enemy before the enemy can see them. This is not a Roblox problem, this is just how networking goes.

Ran into a small issue when using the module; when a tool DmgPoint comes across multiple DmgPoints packed together on a humanoid, it deals damage according to the amount of DmgPoints hit.

I was just wondering if the fix would be to put a debounce in the sword script itself?
Thanks

Can you clarify this part? Do you have PartMode turned on? The module ignores any successive DmgPoint collisions once 1 DmgPoint has confirmed a hit. Are you sure the amount of hits are 100% equal to the amount of DmgPoints? If you call HitStart/HitStop rapidly, this will also reset the collision logic, allowing DmgPoints to start listening for hits again.

A debounce would fix it, but technically shouldn’t be needed since the module does that for you (well, filters the other DmgPoints at least)

character
Thank you for your reply,
I checked and the sword has partMode set to true (I was using the test.rblx with the dummies). It seems like it’s dealing damage proportionate to the more condensed parts of a character (usually 40+ dmg when across the shoulders and 20+ when slashing a single shoulder)

Here is a streamable showcasing what happens: https://streamable.com/wh9aht

1 Like

Yeah if you want the sword to damage once, try setting partmode off or false. PartMode is designed to replicate the normal touched behaviour. What you are seeing is intended functionality as the roblox sword also damages that many times.

Thanks for your reply,
I seem to be getting the same issue when turning off PartMode
image

3 Likes

@Lamborghinious

Hi there, sorry for the late reply, did not have time to be on the DevForum but I’m back again. This seems to be the normal behaviour of the linkedswords created by Roblox (I merely ported the damage logic to them and did not edit any other functionality).

The 20+ damage is due to the initial 10 damage hitting a part (upon starting a swing), and then another 10 damage once the sword comes back up, similar to how Touched works. Multiply this damage with the amount of parts in the humanoid (and where the sword intercepted) and you got yourself the logic you witnessed.

If you require precise damage (such as only 10 damage through the entire swing), you will need to modify the sword script a little, such as removing :HitStop() and only using HitStop() after the swing is completed.

I may make another sword example that doesn’t use LinkedSwords since I do feel it’s not a good representation of the module.


Teaser for Version 3.31 (coming soon)

This minor update is targeted towards users looking to use this module for mesh deformation. I am currently testing performance and will update once I can confirm my production game runs without issue with this update. This will be exclusive to SetPoints as attachments do not work with mesh deformation bones (as of this post).

7 Likes

Hi, is there any way I can stop the .OnHit event from firing only once without restarting it? I would like to damage multiple targets at once.

1 Like

The module already damages multiple targets at once. It just cannot hit the same target(s) you hit again until you hitstop. Do you mean hitting the same target again?

1 Like

Oh, sorry, it was an error with my script.
I had a bunch of AI with the same name “Guard”, and in the script that’s supposed to damage multiple guards, it adds their name to a table and checks if that name is already there.

1 Like

Sorry for bothering but how exactly do you make animations which work with this system?

I’m purely new to animation and I knew nothing, I’ve read this topic and did everything.

However, the rays don’t move at all and only move when the actual player moves. Take a closer look here: https://gyazo.com/221a3f3bb61ee8e7d0d8f0c897c023de

Is it an animation problem or is it my code problem? I’m pretty sure my code is fine, my best guess was that the attachments’ positions didn’t move together with the part. But I’m unsure, thanks!

I used Moon Animator to animate, SetPoints instead of making attachments for the hitbox

Animations should work right out of the gate with this module. There are pretty much only two things that can cause this:

  1. Your code. I don’t see any code so it’s hard to say much about it but you should be using SetPoints on the actual weapon and not torso for example (so the weapon influences the rotation of the raycasts).

  2. Replication issue. If this module is on the serverside, Server sees the position of your weapon differently from what the client sees. A good way to test if its your code or simply replication issue is to use attachments instead of SetPoints just to see if the issue still persists. If it does, it a roblox replication issue and the only solution at this time is to put the hit detection logic on the client side. If it works, it will be your code that is the root problem.


Again, im just speculating since I haven’t seen your script.

I tested it out and turns out it’s the replication issue. Do I just implement my system on the client side now?

I also used a loop to check the position of my sword. Turns out it actually changes its position on the client, but on the server nothing changes at all. What should I do? Could it be a problem from the new animator? (I used this module a while ago with LoadAnimation and it worked just as fine)

Visualization: https://gyazo.com/9b1bbfb017ea142db66ddda0bdba40c1

Edit: Visualization

Question, does this work with projectiles? Like grenades or bow arrows. Just checking because I tried this on the server and it isn’t the best hitbox on the server, should I switch to the client and replicate it, or am I doing something wrong with the hitbox attachments.

Unfortunately I’m actually not sure what causes the replication bug (I only seen it but never experienced it. Its a question that engineers or other people can give), only that putting the module client sided and then sending the target it hit to the server (with sanity checks) is the workaround. Unless there are some ways to fix the replication bug, putting it on the client is the only suggestion I can give at this time.


@rutheniumm This module can be used for projectiles however was not intended for that use. While it can be easily setup for projectiles, I would actually recommend FastCast for that since you will have more control over things like gravity (and also uses raycasting as a solution). You are experiencing server sided latency which is not the best experience, so yeah you can go with client sided preferably for maximum responsiveness or try the FastCast module instead which is designed specifically for projectiles.

If you want to keep using this module, there are a few solutions.

  1. Again, putting it through the client side with serversided sanity checks. This ensures the user gets the best experience with a little bit more work on the security.

  2. Increase the width of the hitbox with more attachments on the server to compensate for latency.