Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local skipId = 106323481
- local dataStoreService = game:GetService("DataStoreService")
- local mps = game:GetService("MarketplaceService")
- local stageDataStore = dataStoreService:GetDataStore("stageStore")
- game.Players.PlayerAdded:Connect(function(plr)
- local leaderstats = Instance.new("Folder")
- leaderstats.Parent = plr
- leaderstats.Name = "leaderstats"
- local stage = Instance.new("IntValue")
- stage.Parent = leaderstats
- stage.Name = "Stage"
- stage.Value = 0
- local data
- local success, errormessage = pcall(function()
- data = stageDataStore:GetAsync(plr.UserId.. "-Stage")
- end)
- if success then
- print(tostring(plr).. "'s data was successfully retrieved.")
- stage.Value = data
- if stage.Value == 0 then
- stage.Value = 0
- repeat wait() until plr:FindFirstChild("TempStage")
- plr.TempStage.Value = 0
- plr:LoadCharacter()
- end
- elseif errormessage then
- warn(tostring(plr).. "'s data had an issue loading.")
- warn(errormessage)
- stage.Value = 0
- end
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- print(tostring(plr).. " is leaving the game.")
- local success, errormessage = pcall(function()
- stageDataStore:SetAsync(plr.UserId.. "-Stage", plr.leaderstats.Stage.Value)
- end)
- if success then
- print(tostring(plr).. "'s data was successfully saved.")
- elseif errormessage then
- warn(tostring(plr).. "'s data had an issue saving.")
- warn(errormessage)
- end
- end)
- mps.ProcessReceipt = function(info)
- local plr = game.Players:GetPlayerByUserId(info.PlayerId)
- if info.ProductId == skipId then
- plr.leaderstats.Stage.Value += 1
- plr:LoadCharacter()
- end
- return Enum.ProductPurchaseDecision.PurchaseGranted
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement