RIPPER0NI’s tutorial on saving multiple values by a table. Be careful with this one, because they didn’t actually use PCalls around the saves, which is really dangerous. Be sure to add them if you are following his tutorial, since they are really important.
In Lumber Tycoon 2 on Roblox, you can create a saving and loading system using the following steps:
First, you will need to decide on a storage method for your save data. You can use Roblox’s DataStore service to store player data, or you can use a custom server solution such as a SQL database.
Next, you will need to create a way for the player to save their progress. This can be done using a GUI button or a hotkey. When the player initiates the save, you will need to gather all of the relevant information about the player’s progress (such as the position of their character, the items in their inventory, etc.) and store it in the chosen storage method.
To load the save data, you will need to create a way for the player to initiate the load process. This can be done in a similar way to the save process, using a GUI button or hotkey. When the player initiates the load, you will need to retrieve the relevant data from the storage method and use it to restore the player’s progress in the game.
You will also need to handle errors and edge cases, such as what happens if the player tries to load a save that does not exist, or if the storage method is unavailable for some reason.
I hope this helps! Let me know if you have any questions.
Here is an example of how you might implement a saving and loading system using Roblox’s DataStore service:
-- Import the DataStore service
local DataStore = game:GetService("DataStoreService")
-- Create a DataStore for saves
local saveDataStore = DataStore:GetDataStore("SaveData")
-- Function to save the player's progress
function saveProgress()
-- Gather the relevant information about the player's progress
local saveData = {
position = player.Character.HumanoidRootPart.Position,
health = player.Character.Humanoid.Health,
inventory = player.Character.Backpack:GetChildren(),
}
-- Save the data to the DataStore
saveDataStore:SetAsync(player.UserId, saveData)
end
-- Function to load the player's progress
function loadProgress()
-- Attempt to retrieve the save data from the DataStore
local saveData = saveDataStore:GetAsync(player.UserId)
-- Check if save data was found
if saveData then
-- Restore the player's progress using the save data
player.Character.HumanoidRootPart.Position = saveData.position
player.Character.Humanoid.Health = saveData.health
for _, item in pairs(saveData.inventory) do
item.Parent = player.Character
end
else
-- Handle the case where no save data was found
print("No save data found for player")
end
end
-- Bind the save and load functions to GUI buttons or hotkeys
saveButton.MouseButton1Click:Connect(saveProgress)
loadButton.MouseButton1Click:Connect(loadProgress)
This is just one example of how you could implement a saving and loading system in Lumber Tycoon 2. There are many other ways you could do it, and you may want to customize the system to fit your specific needs.
I hope this helps! Let me know if you have any questions.
Thanks for the resources, but I have some questions. Can RIPPER0NI’s tutorial allow me to make it so that if the player clicks on a button, it loads the data store assigned to it? And also, what are Pcalls, and what is the best way to use them? Thanks again!
(Sorry if I sound like someone who doesn’t know much about datastores, its because I am )
For loading specific datastores, you’ll need to create GUI buttons for them, and then call :GetAsync(player.UserID) for the respective load slots when the MouseButton1Click event is triggered on them. PCalls are really important in DataStores. Let’s suppose there was an error in the datastore, for whatever reason. Without P-Calls, there would be no way to know if a datastore save/load had succeeded or not. Wrapping a P-Call around a function means that you will know if it has failed or succeeded - I hope you can see why this would be important in DataStores.
Thanks for letting me know what pcalls are and how to get data when a player clicks a button. The reason I haven’t marked this as a solution yet is that I haven’t tried it yet. Once I do and it works, I will mark this as a solution! If it doesn’t work, I’ll reply to you with the problem! Thanks again!
The following post is a WIP (Work in Progress). The content in this post is not final and may be subject to change.
Hello, I am trying to create a Saving/Loading System that is like Lumber Tycoon 2’s saving/loading system.
I don’t know how to make one/ where I can start.
I did search on the dev forum, youtube, and google, but there was nothing related to my problem
Anything that can help/guide me in the right way is greatly appreciated!
Recommending sources that are related to this is also appreciated!
Thank you for taking the time to read this!
We shouldn’t need to ask for it in Luau, Luau is Roblox’s native language.
A developer can’t really use your code (not trying to be offensive) because it’s not in Luau, provided they don’t know C#