when i have this script in ServerScriptService it only adds "Total"
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Toal = Instance.new("IntValue",leader)
Toal.Name = "Total"
Toal.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Toal.Value)
Toal.Changed:connect(function()
ds:SetAsync(player.UserId, Toal.Value)
local Money = Instance.new("IntValue",leader)
Money.Name = "Money"
Money.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Money.Value)
Money.Changed:connect(function()
ds:SetAsync(player.UserId, Money.Value)
end)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Total.Value)
ds:SetAsync(player.UserId, player.leaderstats.Money.Value)
end)

1 comment
the reason why is because ur making instance.new money inside of the toal.Changed function