Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make guns ignore hats?

I have a ray casting pistol but if you hit a hat it doesn't register. Things I've tried to get it to find the humanoid through the hat.

local hum = hit.Parent:FindFirstChild("Humanoid")
if not hum then
	hum = hit.Parent.Parent:FindFirstChild("Humanoid")
end

1 answer

✓ Accepted answer

First, you check if the name of the hat. Hats work like tools, they need a part named "Handle" to work. Here is the code. Only for checking.

if hit.Name == "Handle" and hit.Parent:IsA("Accoutrement") then -- Accessories and hats (deprecated) inherit from this class. 

 -- do code 
end

2 comments

0

Okay thanks. So this here would find the hats and to ignore them I would do (if hit.Name ~= "Handle")?

0

If you wanted to ignore the hats (players cannot take damage from hat hits) then yes

This discussion is preserved as it was. New answers, comments, and votes are closed.