(post deleted by author)
Just do a check on how many said turn pieces have been placed. If its more than 3 then place the opposite turn piece.
Strange thing you’re doing there, I don’t get the purpose?
Either way, Doors mainly fixes this through just deleting the rooms behind you. It also does something similar to a getpartsinboundingbox check on the newly generated room, and if that room overlaps with anything, it despawns the prior rooms, generates a new room again, and force tp’s everyone to that room.
There’s many other ways you could solve it too, but those require a bit more of an algorithmic approach if you need a linear level. What @NoxhazeI said won’t work because you will still end up turning in on yourself. E.g if you start with one left turn, then follow with 3 right.
Sure if the design of your individual rooms allow for such an approach(And the map doesn’t need to be so big that you approach floating point precision errors). It makes the level design pretty predictable though
welp that didnt work either
If that doesn’t work, it’s an issue with your script. I’d have to see the full code to know what you’re doing wrong.
local LastTurnRoom = "Left"
local pRoom = "nil"
function GenerateRoom_()
local randomRoom = Rooms:GetChildren()[math.random(1, #Rooms:GetChildren())]
local chosenRoom:Model = randomRoom:Clone()
local TurnValue = chosenRoom:FindFirstChildOfClass("ValueBase")
if TurnValue then
if string.find(TurnValue, "Turn") then
print(LastTurnRoom)
if chosenRoom:FindFirstChild(LastTurnRoom.."Turn") then
GenerateRoom_()
chosenRoom:Destroy()
--TotalSpawned -=
return
else
if LastTurnRoom == "Left" then
LastTurnRoom = "Right"
elseif LastTurnRoom == "Right" then
LastTurnRoom = "Left"
end
end
end
end
if chosenRoom.Name == pRoom then
GenerateRoom_()
chosenRoom:Destroy()
--TotalSpawned -= 1
return
end
pRoom = chosenRoom.Name
chosenRoom.Name = TotalSpawned
TotalSpawned += 1
chosenRoom.PrimaryPart = chosenRoom.Entrance
chosenRoom:PivotTo(prevRoom.Exit.CFrame)
chosenRoom.Parent = RoomsGenerated
prevRoom = chosenRoom
chosenRoom.Exit.Transparency = 1
chosenRoom.Entrance.Transparency = 1
local WaypoinsEntity : Folder = chosenRoom:FindFirstChild("MonsterWaypoints")
if WaypoinsEntity then
for i, wp in ipairs(WaypoinsEntity:GetChildren()) do
if wp:IsA("BasePart") then
wp.Transparency = 1
wp.CanCollide = false
end
end
end
local KeyModel : Model = chosenRoom:FindFirstChild("KeyModel")
if KeyModel then
wait(0.1)
-- LOCKED ROOM :::::::::::DDDDDDDDDDD
local Key:BasePart = KeyModel:FindFirstChild("key")
if Key then
local MiniScript = script.MiniScripts.KeyEquip:Clone()
MiniScript.Parent = KeyModel
MiniScript.Enabled = true
--MiniScript.Name = "..."
MiniScript.Room.Value = chosenRoom
local door = chosenRoom:FindFirstChild("LockedDoor")
if door then
MiniScript.Door.Value = door
end
end
end
-- Wallpaper
local okkk = Color3.fromRGB()
local c = {
Color3.fromRGB(109, 49, 49),
Color3.fromRGB(63, 109, 49),
Color3.fromRGB(118, 120, 0),
Color3.fromRGB(69, 81, 109)
}
okkk = c[math.random(1, #c)]
for i, wallpaper in ipairs(chosenRoom:GetDescendants()) do
if wallpaper.Name == "wallpaper_part" then
if wallpaper:IsA("BasePart") then
-- .. ex..
pcall(function()
wallpaper.UsePartColor = true
end)
wallpaper.Color = okkk
end
end
end
-- BABYGIRL ITS DA FURNITE https://www.doors-roblox-furniture.com/furnitrure/buy
-- RNG FURNITURE
local FurniturePositions = chosenRoom:FindFirstChild("FurniturePositions")
if FurniturePositions then
local Taken = {}
local Total = FurniturePositions:GetChildren()
local FurnitureFolder = GameAssets.Furniture
local All = FurnitureFolder:GetChildren()
local furnitureChance2 = math.random(1,2)
for i, pos in ipairs(Total) do
if pos:IsA("BasePart") then
if pos.Name == "FurniturePosition" then
pos.Transparency = 1
pos.CanCollide = false
end
end
end
local function Thing()
for i, pos in ipairs(Total) do
if pos:IsA("BasePart") then
if pos.Name == "FurniturePosition" then
if furnitureChance2 == 1 then return end
local FurnitureChance = math.random(1,2)
if FurnitureChance == 1 then
if not table.find(Taken, pos) then
local RNGFurniture = All[math.random(1, #All)]:Clone()
RNGFurniture.Parent = chosenRoom
RNGFurniture:PivotTo(pos.CFrame)
table.insert(Taken, pos)
else
Thing() -- REROLL
end
end
end
end
end
end
Thing()
end
end
Your prior image didn’t work, so what is it that doesnt work right now? Does it just overlap with itself like before?
yes it still overlaps
Its a bit cryptic for me without knowing how the models work, do your straight blocks have a turnvalue? Because from my guess it seems you just flip the LastTurnRoom value even when a turn room hasn’t been placed?
it does check if it has a Turn
Yes im aware of the code, but I dont know if the straight model also has a turn value inside. But im guessing it doesnt then.
yeah the straight model doesn’t have it
Okay so its the way youve structured your turning because its able to do the same turn twice in a row. Which it shouldnt.
I just noticed that i made it check the Value, not it’s name
This is how I did it in my quick example for reference.
local Rooms = workspace.Rooms
local lastTurn = nil
local last = workspace.Straight
local function getValidRooms()
local vRooms = Rooms:GetChildren()
for index, v in vRooms do
if v.Name == lastTurn then
table.remove(vRooms, index)
end
end
return vRooms
end
while true do
local validRooms = getValidRooms()
local myRoom = validRooms[math.random(1, #validRooms)]:Clone()
myRoom.Parent = workspace
myRoom:PivotTo(last.SnapEnd.CFrame)
last = myRoom
if myRoom.Name ~= "Straight" then
lastTurn = myRoom.Name
end
task.wait()
end
This part might cause you issues by the way, since you changed the lastTurn value but still deleted the room after. Its probably that actually.