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)

4 comments
Just change the name for reference, e.g replace money with money2, so both values are unique. There's a possibility that when saving it referenced both values since they both are identical.
Ok thanks for your help!
Oh wait I don't think thats the issue. When you went back into studio, did your values change to 0?
No, but it still has the same issue