Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ds = require(script.Parent.DataStore2)
- ds.Combine('MasterKey','Pancakes','Coins','Rubies')
- local DefaultPancakes = 0
- local DefaultCoins = 0
- local DefaultRubies = 0
- game.Players.PlayerAdded:connect(function(Player)
- -- Creating Leaderstats
- local stats = Instance.new('Folder',Player)
- stats.Name = 'leaderstats'
- local Pancakes = Instance.new('IntValue',stats);Pancakes.Name = 'Pancakes'
- local Coins = Instance.new('IntValue',stats);Coins.Name = 'Coins'
- local Rubies = Instance.new('IntValue',stats);Rubies.Name = 'Rubies'
- -- Getting Leaderstats Datastore
- local PStore = ds('Pancakes',Player)
- local CStore = ds('Coins',Player)
- local RStore = ds('Rubies',Player)
- -- Functions for updating leaderstats in-game
- local function SetPancakes(val)
- Pancakes.Value = val
- end
- local function SetCoins(val)
- Coins.Value = val
- end
- local function SetRubies(val)
- Rubies.Value = val
- end
- -- Setting in-game leaderstats to datastore values
- SetPancakes(PStore:Get(DefaultPancakes))
- SetCoins(CStore:Get(DefaultCoins))
- SetRubies(RStore:Get(DefaultRubies))
- -- Updating in-game leaderstats on Datastore update
- PStore:OnUpdate(SetPancakes)
- CStore:OnUpdate(SetCoins)
- RStore:OnUpdate(SetRubies)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement