Recently had the idea of adding randomly generated dungeons inside of my game through plots, thing is i dont know how to make it check if there’s a wall in front of it or not, i know you can use rays but every attempt i’ve made with rays returns everything it goes through as nil, if someone knows how to do this it would be highly appreciated.
Code
local Plots = game:GetService("ServerStorage"):WaitForChild("Assets").PBGPlots:GetChildren()
local Folder = workspace.Generated
local PreviousPlot = Folder:WaitForChild("Regular0")
local ChosenPlot = nil
for i = 1,15 do
if i == 1 then
ChosenPlot = Plots[1]
else
ChosenPlot = Plots[math.random(#Plots)]:Clone()
end
ChosenPlot.Name = ChosenPlot.Name..i
ChosenPlot:SetPrimaryPartCFrame(PreviousPlot.Connector.CFrame)
ChosenPlot.Parent = Folder
PreviousPlot = ChosenPlot
end
(this code doesnt have any ray stuff in it btw, none of my previous attempts worked)