I made this script to save players money that they get in the game. Once they are playing when they earn money and leave the money that they earned does not save for some reason.
Script Here
local DataStore=game:GetService("DataStoreService")
local ds = Datastore:GetDataStpre("MoneySaveSystem")
game.Plauer.PlayerAdded:connect(function(plr)
local leader = Instance.new("Folder", plr)
leader.Name = "leaderstats"
local Money = Instance.new("IntValue", leader)
Money.Name = "Money"
Money.Value = ds:GetAsync(plr.UserId) == 0
ds:SetAsync(plr.UserId, Money.Value)
Money.Chance:Connect(function()
ds:SetAsync(plr.userId, Money.Value)
end)
)
end)
game.Players.PlayerRemoving:connect(function(plr)
ds:setAsunc(plr.UserId, plr.leaderstats.Money.Value)
end)
What did I do wrong in the script |