Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game.ReplicatedStorage.add.OnServerEvent:Connect(function(plr)
- plr.leaderstats.Coins.Value += 1
- end)
- local datastore = game:GetService("DataStoreService"):GetDataStore('Data')
- game.Players.PlayerAdded:Connect(function(plr)
- local data = datastore:GetAsync(plr.UserId)
- local l = Instance.new("Folder")
- l.Name = 'leaderstats'
- l.Parent = plr
- local value = Instance.new('IntValue')
- value.Name = 'Coins'
- print(data)
- if data then
- value.Value = data['Coins']
- end
- value.Parent = l
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- datastore:SetAsync(plr.UserId,{
- ['Coins'] = plr.leaderstats.Coins.Value
- })
- end)
Add Comment
Please, Sign In to add comment