Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local datastore = game:GetService("DataStoreService"):GetDataStore("Divine'sHats")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder")
- leaderstats.Parent = player
- leaderstats.Name = "leaderstats"
- local cash = Instance.new("NumberValue")
- cash.Parent = leaderstats
- cash.Name = "Cash"
- local power = Instance.new("NumberValue")
- power.Parent = leaderstats
- power.Name = "Power"
- local rebirths = Instance.new("NumberValue")
- rebirths.Parent = leaderstats
- rebirths.Name = "Rebirths"
- local debounce = Instance.new("BoolValue")
- debounce.Value = false
- debounce.Name = "Debounce"
- debounce.Parent = player
- local key = "user-" .. player.userId
- local storeditems = datastore:GetAsync(key)
- if storeditems then
- cash.Value = storeditems[1] --Value of the cash, change "points" if you changed line 10
- rebirths.Value = storeditems[2]
- power.Value = storeditems[3]
- else
- local items = {cash.Value, rebirths.Value, power.Value}
- datastore:SetAsync(key, items)
- end
- end)
- game.Players.PlayerRemoving:connect(function(player)
- local items = {player.leaderstats.Cash.Value, player.leaderstats.Rebirths.Value, player.leaderstats.Power.Value}
- local key = "user-" .. player.userId
- datastore:SetAsync(key, items)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement