I’m making a third person gun system here, and my first major problem has come alight. I can’t damage people when they wear accessories that block body parts… I’m using fastcast, is there a way to fix this?
You have two options:
- Set
CanQuery
to all accessory handles tofalse
- Blacklist the accessories from raycasting (FilterDescendantsInstances of RaycastParams).
I was just researching that second one, do I just list the type as “Accessory” inside the param? Or what
EDIT: That’s not the case, just tried it.
You need to create an array of them. For example,
{Dummy.Hat.Handle, Dummy.Clothing.Handle}
But you would need to insert these automatically.
So how would that work for if people of all kinds are joining the game? Surely there’s an easier way to input them? Can I fit a for loop in there to catch anything with the name of “Accessory”?
They won’t be all named accessory.
Try this and put it in a server script:
function check(d)if d:IsA("Accessory") then pcall(function()d.Handle.CanQuery=false end) end end
for _,obj in pairs(workspace:GetDescendants())do check(obj) end
workspace.DescendantAdded:Connect(check)
They won’t be all named accessory.
I mean the Class name. All hats/accessories have the Accessory ClassName
That didn’t end up helping, as again I’m using fastcast as my weapons module base, and it didn’t register.
I was having the same issue as you, i solved this like Subtotal did, but we gives some time for the accessories to load in.
Put this in a script:
game.Players.PlayerAdded:Connect(function(player) --Detects when a player joins
player.CharacterAdded:Connect(function(char) --Detects when the player's character is loaded
wait(.1) --Wait for the accessories to load
for i,v in pairs(char:GetChildren()) do --This will check every character's content
if v:IsA("Accessory") then --If the child is an accessory then
if v.Handle then --Check if the child has a handle
v.Handle.CanQuery = false --Disables the CanQuery property from the handle
end
end
end
end)
end)
Probably, not the most efficient way of doing this, but i hope this helped you.