Hello! I’m working at a gun, and I need it to be able to fire though invisible/cancollide off parts.
I cannot use Collisions groups
So I have 2 things I can do
Use Mouse.TargetFilter (I can’t pass a table, only Instances)
When the ray hits a part, if its invisible ray again from the place it got hit and ray again to the direction (I don’t know how)
Current code:
Client:
local DisableList = {}
local function Raycast(Pos)
local hitRay = Ray.new(Tool.Handle.Position.Position,(Pos-Tool.FirePart.Position).Unit*Settings.Range.Value)
local Hit,EndPos,Dir = workspace:FindPartOnRayWithIgnoreList(hitRay,DisableList,true,true)
return Hit,EndPos,Dir
end
local function GetRaycast()
local Hit,EndPos,Dir
repeat
Mouse.TargetFilter = {}
Hit,EndPos,Dir = Raycast(Mouse.Hit.Position)
if not Hit then
break
else
if Hit:IsA("BasePart") then
if not Hit.CanCollide or Hit.Transparency == 1 then
table.insert(DisableList,Hit)
end
end
end
until true
table.clear(DisableList)
Mouse.TargetFilter = nil
return Hit,EndPos,Dir
end
Errors that I can only use Instances in Mouse.TargetFilter
Server code:
local DisableList = {}
local function Raycast(Pos1,Pos2)
local hitRay = Ray.new(Handle.Position,(Pos2-Pos1).Unit*Settings.Range.Value)
local Hit,EndPos,Dir = workspace:FindPartOnRayWithIgnoreList(hitRay,DisableList,true,true)
return Hit,EndPos,Dir
end
local function GetRaycast(Pos2)
local Hit,EndPos,Dir
local Pos1 = Tool.FirePart.Position
repeat
Hit,EndPos,Dir = Raycast(Pos1,Pos2)
if not Hit then
break
else
if Hit:IsA("BasePart") then
if not Hit.CanCollide or Hit.Transparency == 1 then
table.insert(DisableList,Hit)
--Pos1 = EndPos
--Pos2 = EndPos * ()
end
end
end
until true
table.clear(DisableList)
return Hit,EndPos,Dir
end