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

How would I make a triple saving leaderstats? (Gold, Exp, Level)

Asked by
Nozazxe 107
3 years ago

I know how to make double save, but not triple. I’ve looked for it on YouTube but can’t find one. Can someone help me?

0
can i have the double save Jakob_Cashy 79 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GoldSaveSystem")
local ds2 = datastore:GetDataStore("ExpSaveSystem")
local ds3 = datastore:GetDataStore("LevelSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstats"
 local Gold = Instance.new("IntValue", folder)
 Gold.Name = "Gold"
 local Exp = Instance.new("IntValue", folder)
 Exp.Name = "Exp"
 local Level = Instance.new("IntValue", folder)
 Level.Name = "Level"

 Gold.Value = ds1:GetAsync(plr.UserId) or 0
 ds1:SetAsync(plr.UserId, Gold.Value)

 Exp.Value = ds2:GetAsync(plr.UserId) or 0
 ds2:SetAsync(plr.UserId, Exp.Value)

Level.Value = ds3:GetAsync(plr.UserId) or 0
 ds3:SetAsync(plr.UserId, Level.Value)

 Gold.Changed:connect(function()
  ds1:SetAsync(plr.UserId, Gold.Value)
 end)

 Exp.Changed:connect(function()
  ds2:SetAsync(plr.UserId, Exp.Value)
 end)

Level.Changed:connect(function()
  ds3:SetAsync(plr.UserId, Level.Value)
 end)
end)

this works it also creates the leaderstats as well

0
Thanks mate Nozazxe 107 — 3y
Ad

Answer this question