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

Ray ignores Hats, but not Accessories?

Asked by 5 years ago
Edited 5 years ago

So i have these lines of codes, they are about getting ALL the hats (and also accessories) handles from the workspace into a table for my gun system. When I shoot someone's head, if they are wearing Hats, then the ray will go through the hat, but not with Accessory.

When I try to print out the names of the handles, the handle names of the accessories are there, but somehow the ray still couldn't go through them.

Forgot to mention that this code is in a local script

I've tried some free model guns, some have the ability to go through hats and accessories, but some don't. Some of them are way too long for me to understand. So I decided to ask here for solutions

0
Just a quick question, why are you trying to ignore accessories? pidgey 548 — 5y
0
If an accessory is part of a character, your guns should be getting the character anyway. Try using FindFirstAncestorOfClass with Model as its argument. pidgey 548 — 5y
0
I'm trying to get the ray to ignore other player's accessory, the local player is fine Konethorix 197 — 5y
0
Forgot to mention that this code is in a local script Konethorix 197 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

OK, so I found out something big and I have to write it as an answer:

After so many attempts, this 1 line was the problem here:

local rayhit,raypos,raynormal = workspace:FindPartOnRayWithIgnoreList(ray, {unpack(hatlist), plr.Character, workspace.CurrentCamera})

If I scramble the orders of the items in the ignore list, like this:

local rayhit,raypos,raynormal = workspace:FindPartOnRayWithIgnoreList(ray, {plr.Character, workspace.CurrentCamera, unpack(hatlist)})

It will actually works, it will actually ignores both hats and accessories, I have no idea why, and I bet nobody will know why. But let's just acknowledge that it happens and follow it.

Ad

Answer this question