Table won't work after certain amount of lines

			['unlockPurchases'] = {
			{rebirthCount = 1,unlock = "HelicopterFake"},
			{rebirthCount = 1,unlock = "Armor5Fake"},
			{rebirthCount = 2,unlock = "TurretFake"},
			{rebirthCount = 2,unlock = "LaserDropper8Fake"},
			{rebirthCount = 3,unlock = "Armor7Fake"},
			{rebirthCount = 3,unlock = "Mechanic2Fake"},
			{rebirthCount = 5,unlock = "ShieldGeneratorFake"},
			{rebirthCount = 5,unlock = "TowerSniper4Fake"},
			{rebirthCount = 6,unlock = "BunkerFake"},
			{rebirthCount = 6,unlock = "ShotgunFake"},
			{rebirthCount = 7,unlock = "Armor8Fake"},
			{rebirthCount = 7,unlock = "HoverboardFake"},
			{rebirthCount = 8,unlock = "HandCannonFake"},
			{rebirthCount = 8,unlock = "LaserGodFake"}

I am updating my game, and adding rebirths 6-8. When I just add the bunker unlock to the table, the tycoon works fine. However, if I add 1+ more to the table after that, the entire tycoon system breaks. Everything is typed out properly, is there something I should know about tables here?

nah you can have huge tables it’s not a problem with the tables rather your code you use to unlock things

2 Likes

Alright, well here’s all the relevant code that calls the table:

for u = 1,#unlockPurchases,1 do
	unlock[u] = {rebirthCount = unlockPurchases[u].rebirthCount}
	table.insert(unlock[u],unlockPurchases[u].unlock)
	addDependencies(unlock[u],unlockPurchases[u].unlock)

and

						PlayerStatManager:IncrementStat(player,"RebirthCount",1)
						rebirthCountStat = PlayerStatManager:getStat(player,"RebirthCount")
						for u = 1,#unlockPurchases,1 do
							if rebirthCountStat >= unlockPurchases[u].rebirthCount then
								
								PlayerStatManager:ChangeStatInTycoonPurchases(player, unlockPurchases[u].unlock, true)
							end
						end
						callFunctionsIfRebirthIsReached(rebirthCountStat,player)

why not do

for index, unlock_purchase in ipairs(unlockPurchases) do
  unlock[index] = unlock_purchase.unlock
  addDependencies(unlock[index],unlock_purchase.unlock)
end

Nvm I found it.

	local purchases = tycoon:WaitForChild("Purchases")
	while true do
		wait(0.1)
		if #purchases:GetChildren() < 10 then break end

Forgot to delete test code :skull::skull::skull::skull: thx anyways

1 Like