Basically, I’m making a LiDAR game, and I figured how to make raycasting at random in the area around the cursor. (Spread) the random is as follows:
RunService.RenderStepped:Connect(function()
if cooldown == false then
local randomV = Random.new(math.random(1,1000))
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
local tableRay = {
}
for i,part in pairs(localPlayer.Character:GetDescendants()) do
if part:IsA("BasePart") and not table.find(tableRay,part) then
table.insert(tableRay,part)
end
end
for i,part in pairs(localPlayer.Character.Humanoid:GetAccessories()) do
if not table.find(tableRay,part) then
table.insert(tableRay,part)
end
end
rayParams.FilterDescendantsInstances = tableRay
local Spread = 5
local offset = Vector3.new(randomV:NextInteger(-Spread,Spread),randomV:NextInteger(-Spread,Spread),randomV:NextInteger(-Spread,Spread))
local newPos = currentCamera.CFrame.Position + offset
local rayLidar = workspace:Raycast(newPos,currentCamera.CFrame.LookVector * 100000,rayParams)
print(rayLidar)
if rayLidar ~= nil and rayLidar.Instance.Parent ~= workspace.rayParts then
print(rayLidar.Instance)
print(rayLidar.Position)
local clonedPart = ReplicatedStorage.samplePart:Clone()
clonedPart.CFrame = CFrame.lookAt(rayLidar.Position,rayLidar.Position - rayLidar.Normal)
clonedPart.Parent = workspace.rayParts
workspace.graphicBeep:Play()
task.wait(0.01)
end
end
end)
How would I alter this so that it raycasts in a shape, like a square for example?