i dont know how to function this skip stage button
i just have this script in the button:
script.Parent.MouseButton1Click:Connect(function()
local id = 955366611
local plr = game.Players.LocalPlayer
local MP = game:GetService(“MarketplaceService”)
MP:PromptProductPurchase(plr,id)
end)
and this is how my stage script:
local Stages = workspace:WaitForChild(“Stages”)
for i,Stage in pairs(Stages:GetChildren()) do
Stage.Touched:Connect(function(touch)
local humanoid
if touch.Parent:FindFirstChild("Humanoid") then
humanoid = touch.Parent.Humanoid
end
if touch.Parent and touch.Parent.Parent:FindFirstChild("Humanoid") then
humanoid = touch.Parent.Parent.Humanoid
end
if humanoid then
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
local PlayerStage = player.leaderstats.Stage.Value
if tonumber(Stage.Name) == PlayerStage + 1 then
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
elseif tonumber(Stage.Name) > PlayerStage + 1 then
humanoid.Health = 0
end
end
end)
end
i wanna if a player click it ,then it will skip a stage .
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
if productId == 955366611 then
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
end
end
For your normal stage system, did you use a team system or a custom system?
Edit: The solution provided in the post linked here is the answer. To teleport them to the stage, add a player:LoadCharacter() to get the final code.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = game.Players:getPlayerFromUserId(playerId)
if productId == (productidhere) then
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
player:LoadCharacter()
end
end
local players = game.Players:GetPlayers()
local done = 0
for i=1, #players do
if players[i].userId ==receiptInfo.PlayerId then
if receiptInfo.ProductId == 957094505 and done == 0 then
done = 1
players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
done = 0
players[i]:LoadCharacter()
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted