SAVE DATA

local player = game:GetService("Players").LocalPlayer

local cash = player.leaderstats.Points.Value

local dss = game:GetService("DataStoreService"):GetDataStore("Items")

if dss:GetAysnc(player.Id) then
  local d = dss:GetAsync(player.Id)
  cash.Value = d[1]
end

game.Players.PlayerRemoving:Connect(function()
  dss:SetAsync(player.Id, {cash.Value})
end)

LEADERSTATS



game.Players.PlayerAdded:connect(function(player)
     local leaderstats = Instance.new("Model")
     leaderstats.Name = "leaderstats"
     leaderstats.Parent = player
 
     local money = Instance.new("IntValue") 
     money.Name = "Points" 
     money.Value = 0 
     money.Parent = leaderstats 
 end)

Please do not change the whole script, just point out errors. Thanks!

3 comments

0

DataStore is server-sided.You might want to change that in order for it to work. I also suggest wrapping your calls in a pcall (protected call).

0

LLLLLLOLLLLLLLLL

0

Can you post an answer on how to do it?