So, basically the code isnt needed right now. But i'll provide it just in case it was needed.. I am trying to make my life simpler by using csg parts, aka unions, which includes positive and negative parts, however I stumbled into a problem where my raycasting hits a negative part, even though it shouldn't it still does and I am unsure on how to fix it..
Also, a blacklist wont work because if i ignore the entire union then I can shoot through the walls.....
local killRay = Ray.new(workspace.CurrentCamera.CFrame.Position,game.Players.LocalPlayer:GetMouse().Hit.p) local part,dist = workspace:FindPartOnRay(killRay,game.Players.LocalPlayer.Character) if part.Transparency == 1 then print('shots fired') elseif part.CanCollide == true then print('shots fired') else print(part," interferance, returned ",part.Transparency) return end if H.Parent.Parent.Name == "Target" then if game.Players.LocalPlayer:GetMouse().Target then if game.Players.LocalPlayer:GetMouse().Target.Name == "Head" then print('head hit') game.ReplicatedStorage.Remotes.Main:FireServer("Kill",true,true) else print('not the head') game.ReplicatedStorage.Remotes.Main:FireServer("Kill",true,false) end end else game.ReplicatedStorage.Remotes.Main:FireServer("Kill",false) end markHit() end
(Also I am using a gun) When I try to avoid the negative parts, it simply avoids the entire union, when I don't avoid the entire union, then it shoots through the walls and the windows, which is even worse....
I was thinking of making it so that there is a way to get all the parts withing a union, but im not very familiar with it.. Anyways.. I'd appreciate help!