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!
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.
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
coders of roblox made me spam runservice
Is this module ideal for fist combat? (no weapons or anything, just the character)
I think it is, you can create the attachment in the playerâs character via a script.
I use this for first combat in my game. Itâs insanely accurate, would definitely recommend!
I can hurt myself sometimes when i swing any way to fix this?
Use the RaycastParams. This is from the github:
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {MyCharacter} --- remember to define our character!
Params.FilterType = Enum.RaycastFilterType.Blacklist
-- We will construct a new hitbox for our sword
local newHitbox = RaycastHitbox.new(Sword)
newHitbox.RaycastParams = Params --- Define our RaycastParams
--- The raycasts will no longer damage your character or any objects you put in the ignore list!
Hi, Iâm new to the development. Do you think it will be possible to do something like this with your module ?:
This module only provides and detects the most baseline hit detection. So yes. But does not help you create those effects. Those will be up to you.
Do you know what will help me do this??