Message me on roblox > TriickXzoniQ for further questions. But how ever, i save my data in models or instances. For example, your making a rpg, you need to save;
-Gold Currency
-Xp Stats
-Level * Progress*
I've set up my data save to work like so
Player
>Model -- What exactly is being saved <
>Gold --Number Value
>Xp --Number Value
>Level --Number Value
You can use data store so it saves >Model and all of it's contents, and loads it when a player joins. If the player does not have it however, it still loads it. Heres the script;
SavedFile = "File3"
Server = "ServerSet1"
function PlayerAdded(Player)
Player:WaitForDataReady()
if Player:LoadInstance(SavedFile) == nil then
Instance.new("Model",Player).Name = "Stats"
Instance.new("NumberValue",Player.Stats).Name = "Gold"
Instance.new("NumberValue",Player.Stats).Name = "Xp"
Instance.new("NumberValue",Player.Stats).Name = "Level"
elseif Player:LoadInstance(SavedFile) ~= nil then
Player:LoadInstance(SavedFile).Parent = Player
print ('Player Had File')
end
end
function PlayerRemoved(Player)
Player:WaitForChild("Stats")
Player:SaveInstance(SavedFile,Player.Stats)
end
game.Players.PlayerRemoving:connect(PlayerRemoved)
game.Players.PlayerAdded:connect(PlayerAdded)
2 comments
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=128157478 and http://wiki.roblox.com/index.php?title=Data_store
Here's my tutorial on DataStores usage as well. https://scriptinghelpers.org/questions/27426/how-to-use-datastores#30949