So I have this new problem with my room generation module, where the part where it’s supposed to return if the RoomPlacement is not there, is just returning at all times.
I don’t know why it is happening at all, but it could be that I accidentally removed a previous fix of my previous post. (previous previous lol)
Here’s part of the module with the problem marked:
function GenerateRoomType.SquareRoom()
local RandomSquareRoom = SquareRooms[math.random(1, #SquareRooms)]
local RandomRoomPlacement = RoomPlacements[math.random(1, 11)]
local RandomSquareRoomClone = RandomSquareRoom:Clone()
RandomSquareRoomClone.Parent = Workspace
task.wait()
for i, RoomPlacement in pairs(RoomPlacements) do
local Debounce = false
RoomPlacement:SetAttribute("HasBeenChanged", false)
if RoomPlacement or RoomPlacement:FindFirstChild("TouchDetector") then
-->>>>>if RoomPlacement.Destroying then--<<<<< PROBLEM OF THE CODE IS HERE
print("Rrremoved")
return
end
task.wait()
RoomPlacement.TouchDetector.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and not Debounce and not RoomPlacement:GetAttribute("HasBeenChanged") then
Debounce = true
RoomPlacement:SetAttribute("HasBeenChanged", true)
RoomPlacement.CanTouch = false
if RandomSquareRoomClone.PrimaryPart and RoomPlacement then
RandomSquareRoomClone.PrimaryPart.CFrame = RoomPlacement.CFrame
else
if not RandomSquareRoomClone.PrimaryPart then
Controls:Disable()
local NewRandomSquareRoomPrimaryPart = Instance.new("Part")
NewRandomSquareRoomPrimaryPart.Parent = RandomSquareRoomClone
NewRandomSquareRoomPrimaryPart.Size = Vector3.new(84, 13.44, 84)
NewRandomSquareRoomPrimaryPart.Material = Enum.Material.Rock
NewRandomSquareRoomPrimaryPart.Color = Color3.new(math.random, math.random, math.random)
RandomSquareRoomClone.PrimaryPart = NewRandomSquareRoomPrimaryPart
end
if not RoomPlacement then
Player.Character:PivotTo(Workspace.SpawnLocation.CFrame)
return
end
end
task.wait(0.1)
RoomPlacement:Destroy()
task.wait(0.3)
CleanUpWildSquareRooms(RoomPlacement)
task.wait(3)
Debounce = false
end
end)
else
print("TouchDetector Is Gone")
end
end
--ReplicatedStorage:WaitForChild("RoomGenerated"):Fire()
end
Any help is appreciated ![]()