Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you make guns ignore hats?

Asked by 6 years ago

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

Log in to vote
3
Answered by 6 years ago

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
0
Okay thanks. So this here would find the hats and to ignore them I would do (if hit.Name ~= "Handle")? SimpleFlame 255 — 6y
0
If you wanted to ignore the hats (players cannot take damage from hat hits) then yes User#19524 175 — 6y
Ad

Answer this question