Now I have seen other similar questions on various sites, including this one, and I just can't seem to get this to work using the advice from anyone. All I'm trying to do is to get the ray to ignore the part that the ray has created. I have tried simply making the part itself ignored, adding folders, creating tables, etc. Nothing works. Any help is greatly appreciated and I sincerely apologize for asking a question more than once on the site, but I was unable to figure it out using the previous posts. Thank you.
local play = game.Players.LocalPlayer
local mouse = play:GetMouse()
local tool = script.Parent
local equipped = false
local fire = false
function Shoot(pos,laser)
if fire == true then
repeat
wait()
local folder = workspace.Folder
local startCFrame = tool.Handle.CFrame
local normal = startCFrame.LookVector
local position = startCFrame.Position
local ray = Ray.new(position, normal * 500)
local hit, position, surfaceNormal = workspace:FindPartOnRayWithIgnoreList(ray,{folder}) --problem is here
laser.Size = Vector3.new(0.4, 0.4, (mouse.Hit.p - tool.Handle.Position).Magnitude)
laser.CFrame = CFrame.new(tool.Handle.Position:Lerp(mouse.Hit.p, 0.5), mouse.Hit.p)
until fire == false
laser:remove()
end
end
mouse.Button1Up:connect(function()
fire = false
end)
mouse.Button1Down:connect(function()
if equipped then
fire = true
local laser = Instance.new("Part")
laser.Name = "Laser"
laser.TopSurface = Enum.SurfaceType.Smooth
laser.BottomSurface = Enum.SurfaceType.Smooth
laser.Size = Vector3.new(0.2, 0.2, 0.2)
laser.BrickColor = BrickColor.new("Bright red")
laser.Anchored = true
laser.CanCollide = false
laser.Locked = true
laser.CFrame = tool.Handle.CFrame
laser.Parent = workspace.Folder
Shoot(mouse.Hit.p,laser)
end
end)
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
fire = false
end)

1 comment
Are you sure it wasn't an issue with FindPartsOnRayWithIgnoreList? You were only blocking out the folder, not the parts inside the folder.