As seen in the title, I am trying to make a late game kind of tycoon. In order for that late game content to be possible, the tycoon needs to be saved, specifically the buildings, please tell me how?
Nobody is going to give you an answer unless you post some already-existing code. However, I will provide some links and examples to guide you in the correct direction.
Depending on what tycoon kit you're using, you can grab all of the items that is in the Purchased folder (or what ever its called) with :GetChildren. For example, if my purchases were located in game.Workspace.Tycoon.Purchases, I can insert all of the children into a table.
local itemTable = {} for i,v in pairs(game.Workspace.Tycoon.Purchases:GetChildren()) do table.insert(itemTable, v) end
This code effectively puts all children into a table format.
Now, DataStore, the service you should use to save, has limitations, and you cannot directly save tables. So, try inserting the name of the object instead of the object itself, as shown here:
local itemTable = {} for i,v in pairs(game.Workspace.Tycoon.Purchases:GetChildren()) do table.insert(itemTable, v.Name) end
Now that we have a table of item names, we can convert this table into a string format for saving. HttpService has a built in feature to do this, also known as JSONEncode.
local itemTable = {} for i,v in pairs(game.Workspace.Tycoon.Purchases:GetChildren()) do table.insert(itemTable, v.Name) end local condensedData = game:GetService("HttpService"):JSONEncode(itemTable)
Now that you have a string format of the purchases, save it with a unique key and DataStore.
local dataStore = game:GetService("DataStoreService"):GetDataStore("ItemSave") local itemTable = {} for i,v in pairs(game.Workspace.Tycoon.Purchases:GetChildren()) do table.insert(itemTable, v.Name) end local condensedData = game:GetService("HttpService"):JSONEncode(itemTable) local playerObject = game.Players.Player1 dataStore:UpdateAsync(playerObject.UserId, function() return condensedData end)
You have successfully saved the player's purchases into your game! Make sure you understand that this code will not work in-game, as the playerObject points to a specific player. Grab players and save them one by one if needed to get around this problem. Use examples I have shown you above to help you.
Now that you've saved, you can use the following code to get data:
local playerObject = game.Players.Player1 game:GetService("DataStoreService"):GetDataStore("ItemSave"):GetAsync(playerObject.UserId)
Here are some other links that will help you along the way: http://wiki.roblox.com/index.php?title=API:Class/DataStoreService http://wiki.roblox.com/index.php?title=API:Class/Instance/GetChildren http://wiki.roblox.com/index.php?title=API:Class/HttpService http://wiki.roblox.com/index.php?title=Global_namespace/Table_manipulation
Hopefully this helped. If it did, give it an upvote! :) (edited to make links clickable)