Why are the values in leaderstats the same?
Hi, so I was making leaderstats and when I tried out my game in Roblox(not Roblox Studio), I sold my items so my Money
increased. But when I went back into Roblox Studio, my Money
and Stored
value becomes the same, is there any fix for this? I have tried to solve it many times but it didn't work. Any help is appreciated!
Here's the code:
01 | local dataStore = game:GetService( "DataStoreService" ):GetDataStore( "MoneyData" ) |
05 | game.Players.PlayerAdded:Connect( function (plr) |
07 | local leaderstats = Instance.new( "Folder" ) |
08 | leaderstats.Name = "leaderstats" |
09 | leaderstats.Parent = plr |
11 | local money = Instance.new( "IntValue" ) |
13 | money.Value = dataStore:GetAsync(plr.UserId) or starterMoney |
14 | money.Parent = leaderstats |
16 | local money = Instance.new( "IntValue" ) |
18 | money.Value = dataStore:GetAsync(plr.UserId) or starterMoney |
19 | money.Parent = leaderstats |
23 | game.Players.PlayerRemoving:Connect( function (plr) |
25 | dataStore:SetAsync(plr.UserId, plr.leaderstats.Money.Value, plr.leaderstats.Stored.Value) |