ok i'm making a tycoon game and i'm trying to implement a save system. i have made some code that successfully saves the data (or so i've seen) but the loading data is the problem. i saved all purchased objects into a table, then inserted the purchased objects table into another table along with the players cash amount. when loading the tycoon, i pull out a clone from which i get the purchases from. then, i made some code that finds all the children of the purchases folder, then checks if the purchase's name is found in the purchased objects table. if so, move the purchase into the purchased objects folder. however, i don't know exactly how to check if the purchase's name is found in the purchased objects table......... i have tried
for i = 1, #purchases do local v = purchases[i] if tycoonData[v] then print('a') end end
but that doesn't seem to work, no errors in the output. help please
To check if an element is inside of a table, you can use table.find(table, element)
. For more information: https://developer.roblox.com/en-us/api-reference/lua-docs/table
Here is the solution:
for i = 1, #purchases do local v = purchases[i] if table.find(tycoonData, v) then print('a') end end
Hope this helped