can this be used to make a shield hitbox?
How can I put the attachments on the players arms?
@epictitanic6g This module does not discriminate hitbox sizes. So yes you can. It is designed to be universal and not simply for swords.
@ErskinePierre I would consider looking up Roblox tutorials or asking around the Building/Support subforum as that is out the scope of this module.
A good starting point on what and how to insert attachments can be found here. This module does not use constraints, but it does use attachments the same way constraints require them.
@TeamSwordphin Hi, I see that the OnHit function has a rayresult thingy but I am looking for the HitPosition of the ray which hit, how would I get it? Im assuming with that rayresult thingy but there isnt much detail about it so idk what to do
It is a RaycastResult parameter. See Documentation:
Hitbox.OnHit:Connect(function(hit, humanoid, raycastResult)
local hitPosition = raycastResult.Position
print(hitPosition)
end)
@TeamSwordphin How much âDmgPointsâ Attachment would be considered a good amount to insert inside a players arm or leg?
General rule I like to use while working with this module is âenough to make it feel good/accurate, but not a lot where there are redundant attachmentsâ. If your hits are not registering, add a bit more attachments.
A good number I generally see myself using is around 9 DmgPoint attachments per hitbox (spread out 1 stud apart). Thicker hitboxes like the arms/legs will need the attachments spread out a little more and in some cases, you might need to add more.
Overall, this module is already quite efficient since raycasting doesnât really net a huge performance overhead so you should be fine running a lot more than 9.
Oh ok thanks ill use a bit more then because sometimes the ray origin is inside a players body part when i punch so it wouldnât register.
Yah it can, I donât see why you think it canât.
I canât believe I only found this module just nowâitâs like all of my combat prayers have been answered! Iâll be implementing the V2.2 Stable into my game over the next couple of days. If I find any bugs Iâll be sure to post them.
Thank you for making this. Itâs seriously a blessing.
even if its an old hitbox, its extremely simple to use and will make for great hitboxes that need to be precise!
This is an excellent release!
Exactly one of the few things I couldnât think of but is an intriguing asset, thank you.
Hey, Iâm having trouble using this. Basically the damage given to the NPC gets multiplied everytime a player swings, For example it starts off at 5 and if a player swings twice it and if the second hit hits an NPC the NPC will be damaged for 10 instead of 5.Heres my code:
â[ Variables ]â
local replicatedStorage = game:GetService(âReplicatedStorageâ)
local Remotes = replicatedStorage:WaitForChild(âRemotesâ)
local SwingRemote = Remotes:WaitForChild(âSwingâ)
local ShovelData = require(game:GetService(âServerScriptServiceâ):WaitForChild(âModulesâ):WaitForChild(âShovelDataâ))
local replicatedData = replicatedStorage:FindFirstChild(âreplicatedDataâ)
local NPCFolder = game.Workspace:FindFirstChild(âNPCâsâ)
local RAYCAST_HITBOX = require(replicatedStorage.Modules.RaycastHitboxV2)
local CanDamage = true
â[ Main ]â
SwingRemote.OnServerEvent:Connect(function(Player)
if CanDamage == true then
CanDamage = false
local playerCurrentShovel = replicatedData:WaitForChild(Player.UserId).CurrentShovel.Value
local Character = Player.Character or Player.CharacterAdded:Wait()
local Shovel = Character:WaitForChild(playerCurrentShovel)
local DamageToTake = ShovelData[playerCurrentShovel].Damage
local newHitbox = RAYCAST_HITBOX:Initialize(Shovel.Handle)
newHitbox:HitStart()
doDamage(Shovel, newHitbox)
wait(.1)
newHitbox:HitStop()
CanDamage = true
end
end)
function doDamage(Shovel, HitBox)
local Character = Shovel.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local playerCurrentShovel = replicatedData:WaitForChild(Player.UserId).CurrentShovel.Value
local DamageToTake = ShovelData[playerCurrentShovel].Damage
HitBox.OnHit:Connect(function(hit, humanoid)
if hit.Parent ~= Character and hit.Parent.Parent == NPCFolder then
local hitNpc = hit.Parent.Humanoid
hitNpc:TakeDamage(DamageToTake)
end
end)
end
You need to disconnect the Hitbox.OnHit function afterwards so the damage doesnât multiply.
local Hitbox = HitBox.OnHit:Connect(function(hit, humanoid) --Hitbox Function
--your code here
end)
Hitbox:Disconnect() --Needed to disconnect the function
Iâm trying to set up hitboxes in both of the players arms.
I could use:
local ArmsHitbox = RAYCAST_HITBOX:Initialize(chr, {chr})
But I have hitbox attachments in the players legs so that wonât work.
Iâve tried using this:
local ArmsHitbox = {RAYCAST_HITBOX:Initialize(chr["Right Arm"],chr["Left Arm"],{chr}}
But the code above doesnât work at all. How can I make it so that it only gets both arms and nothing else?
This may be a stupid question, but does the raycast ignore humanoids if itâs not a direct child of the workspace? I tested this by placing a dummy inside the workspace within a folder, but the raycasts didnât detect the humanoid. Is there a way this can be supported?
The raycast actually can detect humanoids inside folders. There might be an underlying issue with your script.
If you want to do this without using :SetPoints(), you may need to do a bit of hacky method (or til I implement some sort of grouping feature).
You can possibly rename the attachments in the legs to something else for now, then call
local ArmsHitbox = RAYCAST_HITBOX:Initialize(chr, {chr})
and then rename the attachments in the arms to something else, and rename the leg attachments back to DmgPoint, then do
local LegsHitbox = RAYCAST_HITBOX:Initialize(chr, {chr})
Double-check you arenât accidentally putting the folder in the ignore list as well. Otherwise, this module does not discriminate on where parts are descendants of, as long as there is a humanoid it will detect it.
How can I use :SetPoints() to achieve my goal?
My bad, the raycasts DO detect humanoids even if not a direct child of the workspace. However, I noticed that the raycasts were not detecting the humanoids because of differing collision groups. I tested this by changing the the collision groups of two dummies, one with the same collision group as object with the raycast, and the other dummy with a differing collision group. It detected the humanoid of the dummy with the same collision group as the object, but not with the other dummy. Can this be supported?