Script isn't working

Hello! my name is bullet, and today i’ve ran into another issue with my code…

This time, i was working on a generation system for a game, and we wanted to make it everytime you open a door instead of a loop, so i tried to implement that, and here’s how it went:

it generates once [ since the first door has no click detector ]
and then it generates again [ when you open the next rooms door ]
but then, it doesn’t generate or print ANYTHING at all the next room, aka " B-003 " is the last room it generates then it breaks.

Here’s the script:

local PastRoom 
local CurrentRoom = game.Workspace.Rooms.StartRoom
local CurrentDoor
local FutureRoom
local RoomToClone
local RoomNumber1 = 0
local RoomNumber2 = 0
local RoomNumber3 = 1
local CaculNumber = 1
local CaculNumber2 = 1

function Generate()
	RoomNumber3 += 1
	CaculNumber += 1
	CaculNumber2 += 1
	
	if CaculNumber == 10 then
		RoomNumber2 += 1
		RoomNumber3 = 0
		CaculNumber = 0
	end
	
	if CaculNumber2 == 100 then
		RoomNumber1 += 1
		RoomNumber2 = 0
		RoomNumber3 = 0
		CaculNumber2 = 0
		CaculNumber = 0
	end
	
	local Rooms = game.ReplicatedStorage.Rooms:GetChildren()
	
	local RandomNumber = math.random(1,#Rooms)
	
	
	RoomToClone = Rooms[RandomNumber]
	FutureRoom = RoomToClone:Clone()
	FutureRoom:WaitForChild("Plate", 0.5).NumberGUI.Number.Text = "B-"..(RoomNumber1)..(RoomNumber2)..(RoomNumber3)
	local PlacePoint = CurrentRoom:WaitForChild("PastPoint"):WaitForChild("PlacePoint")
	FutureRoom:SetPrimaryPartCFrame(PlacePoint.CFrame)
	task.wait()
	FutureRoom.Parent = game.Workspace.GeneratedRooms
	PastRoom = CurrentRoom
	print(PastRoom)
	task.wait()
	CurrentRoom = FutureRoom
	CurrentDoor = CurrentRoom:WaitForChild("Door")
	
	print("loop")	
end

Generate()

CurrentDoor.Hinge.Door.ClickDetector.MouseClick:Connect(function()
	print("cool!")
	Generate()
end)

If you want more details, ask in the comments.
Thanks for reading, and please help!

I recommend starting to print everything that changes between each cycle for starters.

1 Like

i already did that, it prints nothing on the third one aswell

[ it does change each cycle ]

I mean essentially everything, and I mean everything.

no no, i mean everything, i removed it from the code cause it wasn’t helping and was just flooding the output.

although in the current runs it says the past room is the room that was before the room that you go into [ which is the current when you print the current ] although it says nothing.

Is variable 8 supposed to be equal to 1?

1 Like

yes, why?

30 ch a r a c t e r s

It was different than the other two so it just made me wonder.

1 Like

Try coping the script and then deleting the script
And making a new one with the same code

It happend to me and i did that and works for some reason

1 Like

I already solved it myself, thanks for replying though