wait(0.1)
local part = script.Parent
local char = script.Parent.Parent.ID.Value
local charmodel = game.Workspace:FindFirstChild(char)
local base2 = script.Parent.Parent.Base2
local ignoreparts = charmodel,base2 -- parts to ignore--
local rayfront = Ray.new(part.Position, Vector3.new(0,0,105))
local rayback = Ray.new(part.Position, Vector3.new(0,0,-105))
local rayleft = Ray.new(part.Position, Vector3.new(105,0,0))
local rayright = Ray.new(part.Position, Vector3.new(-105,0,0))
local firingpart = workspace:FindPartOnRay(rayfront,ignoreparts)
local firingpart2 = workspace:FindPartOnRay(rayback,ignoreparts)
local firingpart3 = workspace:FindPartOnRay(rayleft,ignoreparts)
local firingpart4 = workspace:FindPartOnRay(rayright,ignoreparts)
if firingpart ~= nil or firingpart2 ~= nil or firingpart3 ~= nil or firingpart4 ~= nil then
if firingpart:IsA("Part") or firingpart2:IsA("Part") or firingpart3:IsA("Part") or firingpart4:IsA("Part") then
script.Parent.Parent:Destroy()
end
end
Im trying to cast multiple rays in an area to scan for obstacles. If I run this with the lines containing IsA() the rays dont work. but If I remove the line with IsA() the rays do work but are too sensitive and dont properly react.