Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I correct this mistake? I'm trying to make a limit to skipping obby stages.


local productId = 1082662118 -- Change to the ID of your developer product.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
	if game.Players.LocalPlayer.leaderstats.Stage.Value < 5 then
		game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
	else
		script.Parent.Text = "Stage Limit Reached"
		script.Parent.TextColor3 = Color3.new(1, 0, 0)
		wait(1)
		script.Parent.Text = "Skip Stage"
		script.Parent.TextColor3 = Color3.new(1, 1, 1)
	end
end)

I think the problem is the second line of code, but I do not know what to do about it. Edit: If you need the other script, here it is, it should be fine:

MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
local players = game.Players:GetPlayers()

local currency = "Stage"

local done = 0

for i=1,#players do
	if players[i].userId == receiptInfo.PlayerId then
		if receiptInfo.ProductId == 1082662118 and done == 0 then
			done = 1
			players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
			players[i].Character.Humanoid.Health = 0
			done = 0
		end
	end
end
return Enum.ProductPurchaseDecision.PurchaseGranted	
end

12 comments

0

Is this a local script?

0

Is script.Parent a textbutton? Does it prompt the purchase UI? Are you handling the purchase on the server? Where is the script for handling the purchase?

0

iOwn_You, yes, the parent is a textbutton.

0

Also, the other script is completely fine, my real problem is with the limit. I need to make sure that if the player finishes the game that they can't skip the stage again, because if they do, they go back to the start of the game

0

And for the rest of my questions?

0

also yes, it is indeed a local script

0

What is the issue with the skipping exactly?

0

the issue is that the player shouldn't be able to skip stage when they are at the end of the obby. I wanted to make a stage limit where the text button says: "You beat the game, you cannot skip stage again"

0

The skip stage button works, and when i buy it it lets me skip the stage. My problem is that it keeps letting me do it, even when I have completed the obby. This means that I can spend infinite amounts of robux at the last stage.RareUsernameO_O -6 — 4m

0

try player:WaitForChild("leaderstats").Stage.Value

0

that doesnt seem to work

0

You got better at asking questions, nice

1 answer

I assume your problem is that it doesnt let you skip the fourth stage, to fix this in your if statement you want to use <= instead of <

2 comments

0

I have tried that

0

The skip stage button works, and when i buy it it lets me skip the stage. My problem is that it keeps letting me do it, even when I have completed the obby. This means that I can spend infinite amounts of robux at the last stage.

This discussion is preserved as it was. New answers, comments, and votes are closed.