I spent an hour making a skip level button for my friend's game to figure out it doesn't work. When I go from 0 to 1 it works, then when I buy it to go to the 2nd level I go to the 3rd level. Enough talking, here's the code.
local MS = game:GetService("MarketplaceService") function MS.ProcessReceipt(receipt) local Player = tostring(receipt.PlayerId) local character = game.Players:GetPlayerByUserId(receipt.PlayerId).Character local CheckpointData = game.ServerStorage:FindFirstChild("CheckpointData") local PlayerData = CheckpointData:FindFirstChild(Player) if PlayerData then local A = tostring(PlayerData.Value) local LevelWord = "Level" local Number = string.sub(A,#LevelWord+1,#A) local NumberA = tonumber(Number) local NumberB = NumberA+1 local LevelPart = game.Workspace:FindFirstChild("Level"..NumberB) PlayerData.Value = LevelPart character:MoveTo(LevelPart.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4))) else local New = Instance.new("ObjectValue",CheckpointData) New.Name = tostring(receipt.PlayerId) New.Value = game.Workspace.Level1 character:MoveTo(game.Workspace.Level1.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4))) end end
Edit: In case you need it, here is the checkpoint script.
local Players = game:GetService("Players") local ServerStorage = game:GetService("ServerStorage") local checkpoint = script.Parent function onTouched(hit) if hit and hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then local player = Players:GetPlayerFromCharacter(hit.Parent) local checkpointData = ServerStorage:FindFirstChild("CheckpointData") if not checkpointData then checkpointData = Instance.new("Folder") checkpointData.Name = "CheckpointData" checkpointData.Parent = ServerStorage end local userIdString = tostring(player.UserId) local checkpointValue = checkpointData:FindFirstChild(userIdString) if not checkpointValue then checkpointValue = Instance.new("ObjectValue") checkpointValue.Name = userIdString checkpointValue.Parent = checkpointData player.CharacterAdded:connect(function(character) wait() local storedCheckpoint = ServerStorage.CheckpointData[userIdString].Value character:MoveTo(storedCheckpoint.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4))) end) end checkpointValue.Value = checkpoint end end checkpoint.Touched:Connect(onTouched)