Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStore = game:GetService("DataStoreService"):GetDataStore("STAT")
- local function onPlayerAdded(player)
- local plr = game.Workspace:WaitForChild(player.Name)
- local starterGui = game:GetService('StarterGui')
- local stats = Instance.new("Folder", player)
- local clife = Instance.new("StringValue", stats)
- local cash = Instance.new("IntValue", stats)
- local net = Instance.new("IntValue", stats)
- local dead = Instance.new("BoolValue", stats)
- local educated = Instance.new("IntValue", stats)
- local sex = Instance.new("IntValue", stats)
- local data
- local data1
- local data2
- local data3
- local data4
- local data5
- local data6
- pcall(function()
- data = DataStore:GetAsync(plr.UserId)
- data1 = data[1]
- data2 = data[2]
- data3 = data[3]
- data4 = data[4]
- data5 = data[5]
- data6 = data[6]
- end)
- if data4 ~= nil then
- if data1 ~= nil then
- cash.Value = data1
- else
- cash.Value = 0
- end
- if data2 ~= nil then
- clife.Value = data2
- else
- clife.Value = "Life"
- end
- if data3 ~= nil then
- net.Value = data3
- else
- net.Value = 0
- end
- if data4 == false then
- dead.Value = false
- else
- dead.Value = true
- end
- if data5 ~= nil then
- educated.Value = data5
- else
- educated.Value = 0
- end
- if data6 ~= nil then
- sex.Value = data6
- else
- sex.Value = 0
- end
- else
- dead.Value = true
- end
- stats.Name = "leaderstats"
- sex.Name = "sex"
- clife.Name = "clife"
- cash.Name = "cash"
- net.Name = "net"
- dead.Name = "dead"
- educated.Name = "educated"
- plr.Torso.Anchored = true
- end
- local function onPlayerLeave(player)
- local plr = game.Workspace:WaitForChild(player.Name)
- local starterGui = game:GetService('StarterGui')
- local stats = player.leaderstats
- local clife = stats.clife
- local cash = stats.cash
- local net = stats.net
- local dead = stats.dead
- local sex = stats.sex
- local educated = stats.educated
- local data
- pcall(function()
- data = DataStore:SetAsync(plr.UserId, {
- cash.Value,
- clife.Value,
- net.Value,
- dead.Value,
- educated.Value,
- sex.Value
- })
- end)
- end
- game.Players.PlayerAdded:Connect(onPlayerAdded)
- game.Players.PlayerRemoving:Connect(onPlayerLeave)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement