Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeleportService = game:GetService("TeleportService")
- local RoundsDataStore = game:GetService("DataStoreService"):GetDataStore("Rounds")
- local WinsDataStore = game:GetService("DataStoreService"):GetDataStore("Wins")
- local AddRoundsDataStore = game:GetService("DataStoreService"):GetDataStore("AddRounds")
- local AddWinsDataStore = game:GetService("DataStoreService"):GetDataStore("AddWins")
- local CoinsDataStore = game:GetService("DataStoreService"):GetDataStore("Coins")
- local LevelsDataStore = game:GetService("DataStoreService"):GetDataStore("Level")
- local ExpDataStore = game:GetService("DataStoreService"):GetDataStore("Exp")
- local VIPGamepass = (267214996)
- game.Players.PlayerAdded:Connect(function(player)
- local Folder = Instance.new("Folder", player)
- Folder.Name = "leaderstats"
- local Rounds = Instance.new("NumberValue", Folder)
- Rounds.Name = "Rounds"
- Rounds.Value = RoundsDataStore:GetAsync(player.UserId) or 0
- local Wins = Instance.new("NumberValue", Folder)
- Wins.Name = "Wins"
- Wins.Value = WinsDataStore:GetAsync(player.UserId) or 0
- local AddRounds = Instance.new("NumberValue", player)
- AddRounds.Name = "AddRounds"
- AddRounds.Value = AddRoundsDataStore:GetAsync(player.UserId) or 0
- local AddWins = Instance.new("NumberValue", player)
- AddWins.Name = "AddWins"
- AddWins.Value = AddWinsDataStore:GetAsync(player.UserId) or 0
- local Coins = Instance.new("NumberValue", player)
- Coins.Name = "Coins"
- Coins.Value = CoinsDataStore:GetAsync(player.UserId) or 0
- local Levels = Instance.new("NumberValue", Folder)
- Levels.Name = "Levels"
- Levels.Value = LevelsDataStore:GetAsync(player.UserId) or 1
- local Exp = Instance.new("NumberValue", Folder)
- Exp.Name = "Exp"
- Exp.Value = ExpDataStore:GetAsync(player.UserId) or 0
- while wait() do
- if Exp.Value >= (100 * (Levels.Value + 1)) then
- Levels.Value = Levels.Value + 1
- Exp.Value = 0
- end
- end
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepass) then
- player.Coins.Value = player.Coins.Value * 2
- end
- if player.AddWins.Value >= 1 then
- player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
- end
- if player.AddRounds.Value >= 1 then
- player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- RoundsDataStore:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
- WinsDataStore:SetAsync(player.UserId, player.leaderstats.Wins.Value)
- AddRoundsDataStore:SetAsync(player.UserId, player.AddRounds.Value)
- AddWinsDataStore:SetAsync(player.UserId, player.AddWins.Value)
- CoinsDataStore:SetAsync(player.UserId, player.Coins.Value)
- LevelsDataStore:SetAsync(player.UserId, player.leaderstats.Levels.Value)
- ExpDataStore:SetAsync(player.UserId, player.leaderstats.Exp.Value)
- end)
- game:BindToClose(function()
- print("STOPPED!")
- for i,player in pairs(game.Players:GetPlayers()) do
- RoundsDataStore:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
- WinsDataStore:SetAsync(player.UserId, player.leaderstats.Wins.Value)
- AddRoundsDataStore:SetAsync(player.UserId, player.AddRounds.Value)
- AddWinsDataStore:SetAsync(player.UserId, player.AddWins.Value)
- CoinsDataStore:SetAsync(player.UserId, player.Coins.Value)
- LevelsDataStore:SetAsync(player.UserId, player.leaderstats.Levels.Value)
- ExpDataStore:SetAsync(player.UserId, player.leaderstats.Exp.Value)
- print("Saved data for "..player.Name)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement