As a Roblox developer, it is currently hard to save folders with its contents, to the datastore
If Roblox is able to address this issue, it would improve my game / my development experience because it would allow me to focus on developing my game rather than sitting and trying to figure out how to save all contents of an folder
to datastore
.
How it would work?
DataStore
should allow developers to save data / load data, as instances. Instances can be pretty much anything, everything would be saved including properties, it’s like an exact copy saved to the datastore
.
PlayerData as an template
PlayerData after Player playing a game after an month let’s say
An example. Do you see any tables? Nope, not anymore.
local DataStoreService = game:GetService("DataStoreService") -- Get datastore service
local DataStore = DataStoreService:GetDataStore("PlayerData") -- Get datastore
local Players = game:GetService("Players") -- Get players service
local Template = script:WaitForChild("PlayerData") -- Datastore template folder with contents
Players.PlayerAdded:Connect(function(Player) -- When player joins the game
local SavedPlayerData = nil -- Create an variable, empty for rightnow
pcall(function() -- Don't crash entire script if it fails to load saved data
SavedPlayerData = DataStore:GetAsync(Players.UserId) -- Get saved data
end) -- End the statment
if SavedPlayerData ~= nil then -- Saved data is not empty then
SavedPlayerData:Clone().Parent = Player -- Get saved data and clone it, to the player
else -- Or its empty then
Template:Clone().Parent = Player -- Clone the template datastore folder to the player
local PlayerData = Player:WaitForChild("PlayerData") -- Get datastore folder
DataStore:SetAsync(Player.UserId, PlayerData) -- Save the folder to the player id
end -- End the statment
end) -- End the statment
Players.PlayerRemoving:Connect(function(Player) -- When player leaves the game
local PlayerData = Player:WaitForChild("PlayerData") -- Get datastore folder
DataStore:SetAsync(Player.UserId, PlayerData) -- Save the folder to the player id
end) -- End the statment
Why it would be an great feature?
- Less scripting, more time for other stuff.
- Easier to write a datastore script.
- More possibilities with less required experience and potential problems.
Why do you think, it would be an great feature? If not then why not?