Hello, I’m trying to use the Raycast Hitbox module to make a melee game. I’ve encountered an issue when I’ve tried to make the melee detect if it has hit somebody in the head, it detects the player’s head accessories instead of the body part.
The print(hit) line exports the word “Handle” in the console, meaning it hit the accessory’s handle and couldn’t detect the body part.
I’ve tried to detect it as a headshot if hit.Name == “Handle” but that would lead to errors where players would hit the other players on a accessory that isn’t on their head but still register it as a headshot.
I’ve tried to detect if the part is an accessory but it just did not work.
If anybody knows how to fix this and would tell me how, I would appreciate it very much.
local weapon = script.Parent.Parent
local attacktrig = script.Parent.Attack
local headattacktrig = script.Parent.HeadAttack
local idletrig = script.Parent.Idle
local equiptrig = script.Parent.Equip
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ragdollEvent = ReplicatedStorage.Ragdoll
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
local gugushaker = ReplicatedStorage.Remotes.Shakers.GuguShaker
local headshaker = ReplicatedStorage.Remotes.Shakers.HeadShaker
local newHitbox = RaycastHitbox.new(script.Parent)
newHitbox.OnHit:Connect(function(hit, humanoid)
humanoid:TakeDamage(math.random(30,40))
weapon.Handle.HitSFX:Play()
weapon.Handle.Bld1:Play()
print(hit)
if hit.Name == "Head" then
local player = game.Players:GetPlayerFromCharacter(weapon.Parent)
ragdollEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
weapon.Handle.Bld2:Play()
headattacktrig:FireClient(player)
headshaker:FireClient(player)
end
end)
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
weapon.Equipped:Connect(function()
local gug = weapon.Parent
Params.FilterDescendantsInstances = {gug}
local newHitbox = RaycastHitbox.new(script.Parent)
newHitbox.RaycastParams = Params
end)
equiptrig.OnServerEvent:Connect(function(plr)
if plr:IsA("Player") then
weapon.Handle.EquipSFX:Play()
end
end)
attacktrig.OnServerEvent:Connect(function(plr)
if plr:IsA("Player") then
task.wait(0.6)
gugushaker:FireClient(plr)
weapon.Handle.SwingSFX:Play()
newHitbox:HitStart()
task.wait(0.4)
newHitbox:HitStop()
end
end)