Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make leaderboard stats save between places in a universe?

Asked by 8 years ago

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.

2
DataStores. Unlike Data Persistence, DataStores can save information place to place so long as the places are in a single universe/game. M39a9am3R 3210 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

DataStores

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.

How do I save?

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);

How do I load?

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.

Ad

Answer this question