Raycast Hitbox 4.01: For all your melee needs!

SetPoints doesn’t rotate with bones :frowning:

1 Like

Seems like a bug with replication. Does that happen if you put the module client sided as a test? Would you be able to share that exact model to me so I can see if it’s something I can fix?

This issue has been fixed.

2 Likes

Sorry, me again. I noticed that OnHit only allows one connection. I also noticed that signal is set up to basically only be one connection. Is it ever planned to expand this to allow more connections? I plan on adding support for it regardless, but I just want to know if it was planned to add the ability to connect more.

1 Like

Yeah it’s only one connection allowed at this time. Before you could have multiple hooked up but a lot of scripters fell into the trap of hooking OnHit every time they dealt damage which meant that OnHit will fire more and more times, at an exponential rate. So I limited it to 1 so its easier for newer scripters to grasp. This is my reasoning for limiting it. You are free to change that behaviour.

2 Likes

Small, tiny question, is there a way to use this on client? Without having the server to step in?

I don’t see why you cannot use this on the client.

1 Like

Oh, it works on the Client? That’s amazing.

1 Like

Hello. I have followed the GitHub Wiki (Beginner Examples · Swordphin/raycastHitboxRbxl Wiki · GitHub), attempting to create a deadly part. However, it looks like the lines won’t appear and the Humanoid didn’t take any damage. Any help would be appreciated.

I think more information needs to be provided for a solution to your error.

Which particular part did you need help on? Is the module in ReplicatedStorage?

-- << Initial Setup >> 
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)

-- We will construct a new hitbox for our part
local newHitbox = RaycastHitbox.new(script.Parent)

-- We can use SetPoints to create new DmgPoints artificially
newHitbox:SetPoints(script.Parent, {Vector3.new(0, 3, 0), Vector3.new(-5, 3, 0), Vector3.new(5, 3, 0)})

-- Makes a new event listener for raycast hits
newHitbox.OnHit:Connect(function(hit, humanoid)
    print(hit)
    humanoid:TakeDamage(50)
end)

-- Let's just run it on a loop, cause why not?
while true do
    newHitbox:HitStart()
    wait(5)
    newHitbox:HitStop()
    wait(5)
end

And the script is indeed in ReplicatedStorage

Make sure RaycastModule is in ReplicatedStorage.

Then, make sure the script you just posted is in a part. That script also turns off the hitbox every 5 seconds so make sure you aren’t accidentally stopping the test before it can turn itself back on again.

If it still doesn’t work, can you show a picture of your explorer window on how you are placing the scripts?

Very useful module! Keep up the good work!

Before, I was using Touched event. Which is sometimes buggy.
Like, sometimes doesn’t hit and sometimes it hit.
Now! This module saves me a lot!

1 Like

Hey got a question for Version 4.0, does Hitbox:Destroy() also remove the points created using Hitbox:SetPoints(), or do I have to do Hitbox:RemovePoints() and then Hitbox:Destroy()?

Destroy removes those points too.

For V4.0, the OnHit event seems to return nil for the connection, is this intended?

Code

local rp  = game:GetService("ReplicatedStorage")
local mod = require(rp.RaycastHitboxV4)
local p   = script.Parent

local hitBox = mod.new(p)

hitBox:SetPoints(p, {Vector3.new(0, 1, 0),Vector3.new(0, 0, 0),Vector3.new(0, 0, 1),Vector3.new(1, 0, 0)})
local c; c = hitBox.OnHit:Connect(function() warn("hit") end) 
hitBox:HitStart()
warn(c)

Output

 nil  -  Server - Script:10

It is intended yes. Connect uses a custom signal that does not return the listener. If you need it to return something, you can edit the signal module inside the script, and change line 10 - 12 to:

function connection:Connect(Listener)
    self[1] = Listener
    return self --- or equivalent
end

If you need it for disconnecting purposes, just write OnHit with a new function, it will overwrite and will be garbage collected automatically.

1 Like

I just did this quick code for my game.
It doesn’t even work at all, it will work once and that’s all.

		if game.ReplicatedStorage.LocalSettings.Debug.Value == true then
			RaycastModule.DebugMode = true
		else
			RaycastModule.DebugMode = false
		end

DebugMode has been removed in V4 and no longer works that way. If you are using this code for the old raycast module (V3 or prior), it will only work for any newly created hitboxes.

The new and only supported way now is to turn it on (at initial runtime) on line:

-- Show where the red lines are going. You can change their colour and width in VisualizerCache
local SHOW_DEBUG_RAY_LINES: boolean = false

or turn on the hitbox individually:

hitbox.Visualizer = true
1 Like

coders of roblox made me spam runservice