Update: this problem has been solved by kingdom5 over on the SH discord server! All I had to do was find all the accessories in models in the workspace and add them to a list of ignored parts, then use FindPartOnRayWithIgnorList()
with that ignore list. It worked!
I've got a crossbow script that I'm making, where you can charge back the crossbow and you will do damage depending on how much it's charged. If it has less than 90% charge, it will shoot a projectile at a specific speed that ignores accessories and hits targets just fine. However, if it's 90% charged or higher, it will fire a solid raycasted beam that instantly hits its target. The problem is, if the ray hits an accessory, it still counts as a hit and will damage the target. As you can imagine, this means a big disadvantage for anyone with large accessories, and if I add headshots, it means people with hair or certain other hats are at an advantage, since the accessory will be partially or completely blocking their head, meaning it'll be harder to get headshots on them. How would I make it so this raycasting script completely ignores accessories and goes through them instead of counting it as hitting something?
local ray = Ray.new(player.Character.Head.CFrame.p, (mouse.Hit.p - player.Character.Head.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) if part then local humanoid = part.Parent:FindFirstChildOfClass("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChildOfClass("Humanoid") end if humanoid then if humanoid.Health > 0 then local targetplayer = game.Players:GetPlayerFromCharacter(part.Parent) if targetplayer then if targetplayer.TeamColor ~= player.TeamColor or targetplayer.Neutral == true then game.Workspace.DamageHumanoid:FireServer(humanoid, damage, part, script.Parent) end else game.Workspace.DamageHumanoid:FireServer(humanoid, (damage), part, script.Parent) end end end end game.Workspace.StaticBulletBeam:FireServer(BrickColor.new("Gold"), Enum.Material.Neon, 0, 0.5, 0.05, script.Parent.Handle.CFrame.p, position)
Yes, this is the raycasting laser gun script in the wiki, but I've made some important changes, like checking if the target is on your team and FE compatibility. But please, help me out with this. I don't want my game to be unfair for people with wings and people with hair.