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:
local dataStore = game:GetService("DataStoreService"):GetDataStore("MoneyData") starterMoney = 0 game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local money = Instance.new("IntValue") money.Name = "Money" money.Value = dataStore:GetAsync(plr.UserId) or starterMoney money.Parent = leaderstats local money = Instance.new("IntValue") money.Name = "Stored" money.Value = dataStore:GetAsync(plr.UserId) or starterMoney money.Parent = leaderstats end) game.Players.PlayerRemoving:Connect(function(plr) dataStore:SetAsync(plr.UserId, plr.leaderstats.Money.Value, plr.leaderstats.Stored.Value) end)
both values are saving into 1 data store named "MoneyData" for saving "Stored" value you will need a new data store named "MoneyData2" or something