So I'm making an adventure game and I want Coins and Crystals to save between places (worlds) in the game (universe) but I'm literally stumped and I can't come up with anything at all so I'd really appreciate if someone could help me out here.
DataStores allow you to save data across all places in a game. It can only save primitive datatypes and some tables, so complex data will need to be serialized.
You can use DataStore.SetAsync
local DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(); -- Assumes Player to be predefined DataStore:SetAsync(Player.userId..'Coins', Player.leaderstats.Coins.Value); DataStore:SetAsync(Player.userId..'Crystals', Player.leaderstats.Crystals.Value);
You can use DataStore.GetAsync
local DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(); -- Assumes Player to be predefined Player.leaderstats.Coins.Value = DataStore:GetAsync(Player.userId..'Coins') Player.leaderstats.Crystals.Value = DataStore:GetAsync(Player.userId..'Crystals');
Any questions? Ask.