Hey! I’m posting this topic here because I think I won’t get any response on the respective topic.
I’ve been having issues with this module for the couple past months (since I actually implemented it in my game). I started to test a lot using dummies and actual players and it worked always on dummies but only a few times on players, then I joined the game with an alt (and removed any accessory/hair from it) and it worked perfectly.
From this (and more testing to check this out, of course), I realized that this only happens when the DmgPoints (raycasting module attachments) touch an accessory (back accessory, face accessory, hair, etc) before touching an actual character part (LeftArm, RightFoot, UpperTorso, etc), does anyone know how can I fix this? Maybe blacklisting it (via module)? Please I need help.
Instead of blacklisting it, you can use Instance:FindFirstAncestorWhichIsA("Model") on it. Every time the raycast hitbox hit an accessory, the hit instance isn’t the MeshPart of the accessory, and using the function would make the instance keep finding its parent until it founds a model, which is the character model.
But I don’t want to find the model since I can already get the character instance easily, I’ll show you the function (“Hit” is the instance as you may already figured out, “Character” is my character and “character” is victim’s character):
function Blow(Hit)
if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
return
end
local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
if not RightArm then
return
end
local RightGrip = RightArm:FindFirstChild("RightGrip")
if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
return
end
local character = Hit.Parent
if character == Character then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health == 0 then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player) then
return
end
if player then
if character.HumanoidRootPart.Dodging.Value == false then
health_module.TakeClampedDamage(humanoid,Damage)
hit.Parent = character.UpperTorso
hit:Play()
else
if character.HumanoidRootPart.Dodging.Value == true then
dodgeremote:FireClient(player)
end
end
return
end
health_module.TakeClampedDamage(humanoid,Damage)
hit.Parent = character.UpperTorso
hit:Play()
end
You can’t do both of that. If you want the raycast to hit the accessory parts, there’s no need to add any extra programming as the raycast would’ve touched the MeshPart of the accessories.
Yes, but as I said, it is completely cancelling any damage/detection on accessory/accoutrement hit, but when it directly hits a character’s part (such as, like I said: Head, LowerTorso, LeftFoot, etc) it works perfectly.
Well, you have a couple options.
First, you could just switch the Hitbox’s DetectionMode to PartMode or Bypass (if you really need it) and check if the hit’s Parent has a child with the class of Humanoid.
A second option is setting each of the character’s accessories’ handles’ CanQuery to false when their appearance is loaded. I work with this module as well and these are the fixes I had for these issues.
I already tried the first option (DetectionMode) before creating this topic but worked as bad as Default mode.
Just tried the CanQuery solution and I think it actually worked, simple server script I made for it (spoon-feeding I guess):
local Players = game.Players
function PlayerJoined(Player)
local function Query(Character)
for i,v in pairs (Character:GetDescendants()) do
if v:IsA("Accoutrement") then
v.Handle.CanQuery = false
end
end
end
Player.CharacterAdded:Connect(Query)
end
Players.PlayerAdded:Connect(PlayerJoined)
You should change Player.CharacterAdded to Player.CharacterAppearanceLoaded, the hats may load too fast. You can also just use Humanoid:GetAccessories instead of a for loop if you want.
I don’t think hats loading fast may become a problem, but I’ll keep that on mind.
Humanoid:GetAccessories only gets every accessory I think (which is only hats), and I also want to get every other accessory (like a belt for example, which isn’t welded to the head). There is a difference between accessory and accoutrement.
Okay, it’s just when I used CharacterAdded and a player respawned after spawning in the for the first time, the hats would load too fast. If it works fine for you, then maybe it was just a difference in my script.
Changed it to CharacterAppearanceLoaded just in case, but thank you a lot for helping me!
local function CanQuery(Character)
for i,v in pairs (Character:GetDescendants()) do
if v:IsA("Accoutrement") then
v.Handle.CanQuery = false
end
end
end
Player.CharacterAdded:Connect(RemoveMeshes)
Player.CharacterAppearanceLoaded:Connect(CanQuery)