✓ Accepted answer
Well, here it is hope this helps.
First off, a server script can't access the LocalPlayer object. Also that's not a good way to go about doing this.
I'm also adding DataStore for you so it saves it! You're welcome! XD
So do this in a Server script
local startingCashValue = 0
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("MoneyDataStore")
game.Players.PlayerAdded:connect(function(plr)
local leader = Instance.new("Folder")
local cash = Instance.new("IntValue")
leader.Name = "leaderstats"
leader.Parent = plr
cash.Name = "Money"
cash.Parent = leader
cash.Value = ds1:GetAsync(player.UserId) or startingCashValue
end)
game.Players.PlayerRemoving:connect(function(player)
print("Saving Data For "..player.Name.."..")
ds1:SetAsync(player.UserId, player.leaderstats.Points.Value)
print("Data For "..player.Name.." has been saved!")
end)
1 comment
what exactly isnt working?