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

2 leaderstats syncing together?

Asked by
zomspi 541 Moderation Voter
4 years ago

I have 2 leaderboards and the leaderstats inside them are the same every time, even if I change 1, when I leave the game they are the same, they sync together?

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetGlobalDataStore("PotatoesSaveSystem")
local ds1 = DataStore:GetGlobalDataStore("Potatoes1SaveSystem")

game.Players.PlayerAdded:connect(function(player)
 local leader = Instance.new("Folder",player)
 leader.Name = "leaderstats"
 local Potatoes = Instance.new("IntValue",leader)
 Potatoes.Name = "Potatoes"
 Potatoes.Value = ds:GetAsync(player.UserId) or 0
 ds:SetAsync(player.UserId, Potatoes.Value)


local leader1 = Instance.new("Folder",player)
 leader1.Name = "leaderstats1"
 local Credit = Instance.new("IntValue",leader1)
 Credit.Name = "Credit"
 Credit.Value = ds1:GetAsync(player.UserId) or 0
 ds1:SetAsync(player.UserId, Credit.Value)
  Credit.Changed:connect(function()
  ds1:SetAsync(player.UserId, Credit.Value)
end)
  Potatoes.Changed:connect(function()
  ds:SetAsync(player.UserId, Potatoes.Value)
end)


game.Players.PlayerRemoving:connect(function(player)
 ds:SetAsync(player.UserId, player.leaderstats.Potatoes.Value)
ds1:SetAsync(player.UserId, player.leaderstats1.Credit.Value)
end)



 end)







0
How do you change the value? If you work in Studio, and change it in the Explorer, you only change it locally. for the server to detect the change, I suggest you do it with the command box. Spjureeedd 385 — 4y
0
I use the console, but I have a click detector thingy that changes the value zomspi 541 — 4y
0
The console changes only on the client side aswell, use a script or the command box Spjureeedd 385 — 4y
0
I am changing it in the actual game not studio zomspi 541 — 4y

Answer this question