Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Skip Level Product Won't Work?

Asked by 5 years ago
Edited 5 years ago

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.

01local MS = game:GetService("MarketplaceService")
02function MS.ProcessReceipt(receipt)
03    local Player = tostring(receipt.PlayerId)
04    local character = game.Players:GetPlayerByUserId(receipt.PlayerId).Character
05    local CheckpointData = game.ServerStorage:FindFirstChild("CheckpointData")
06    local PlayerData = CheckpointData:FindFirstChild(Player)
07    if PlayerData then
08        local A = tostring(PlayerData.Value)
09        local LevelWord = "Level"
10        local Number = string.sub(A,#LevelWord+1,#A)
11        local NumberA = tonumber(Number)
12        local NumberB = NumberA+1
13        local LevelPart = game.Workspace:FindFirstChild("Level"..NumberB)
14        PlayerData.Value = LevelPart
15        character:MoveTo(LevelPart.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4)))
View all 22 lines...

Edit: In case you need it, here is the checkpoint script.

01local Players = game:GetService("Players")
02local ServerStorage = game:GetService("ServerStorage")
03 
04local checkpoint = script.Parent
05 
06function onTouched(hit)
07    if hit and hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then
08        local player = Players:GetPlayerFromCharacter(hit.Parent)
09        local checkpointData = ServerStorage:FindFirstChild("CheckpointData")
10        if not checkpointData then
11            checkpointData = Instance.new("Folder")
12            checkpointData.Name = "CheckpointData"
13            checkpointData.Parent = ServerStorage
14        end
15 
View all 34 lines...
0
"doesn't work" can mean a lot. Does it show any errors in the output? What exacty happens? Asceylos 562 — 5y

Answer this question