Is this skip stage script right?

I’ve seen this script on a lot of free models for stage skipping on obbies but parts of it have a red underline and it doesnt work for me so can some tell me if its wrong and how I can fix it?

MarketplaceService = Game:GetService("MarketplaceService")

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

currency = "Stage"

done = 0

for i=1,#players do
	if players[i].userId == receiptInfo.PlayerId then
		if receiptInfo.ProductId == 22277159 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
2 Likes

Could you please tell us where is the red underline located?

1 Like

it doesnt show up when i use snipping tool so I had to circle them image

I can tell by looking even without the lines theres something wrong with it but i dont have the scripting knowledge to know what

1 Like

I’ll take the code into studio code editor and I’m going to make some changes on it. I will get back to you once I’m finished!

1 Like

Okay thank you, greatly appreciated.

1 Like
local MarketplaceService = game:GetService("MarketplaceService")
local playersService = game:GetService("Players")

MarketplaceService.ProcessReceipt = function(receiptInfo)
	local currency = "Stage"
	
	local purchasingPlayer = playersService:GetPlayerByUserId(receiptInfo.PlayerId)

	if purchasingPlayer and receiptInfo.ProductId == 1132092375 then
		purchasingPlayer.leaderstats[currency].Value += 1
		purchasingPlayer.Character.Humanoid.Health = 0
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not purchasingPlayer then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

Alright sir, I think I’m finished. I have’t tested it yet, but I think it should work. If you would like to ask me something about the new script, then go ahead! I’m happy to help.

EDIT: The issue with Product ID is now fixed.

1 Like

For some reason I still don’t get teleported to the next stage. At this point I feel like its something to do with my checkpoint system, except now it just prevents me from going to the next stage.

If the script with skipping part did change the Value on leaderstats and it did kill you, then the problem will probably be in your checkpoint script.

Yep it is, my checkpoint script does it so that as soon as you reach the part it sets your spawn there and ups your stage by 1 preventing you from going back, but with the script it ups the leaderboard but keeps your spawn in the same place. I’ll check it and see if I need to change the entire checkpoint system because I feel like I do.

Is your checkpoint script allowing you to get onto previous checkpoints? I mean it like you would be on stage 5 and then you would go back and get the checkpoint number 4. If so, then you could fix it by allowing players get checkpoints just when their health is bigger than 0 (in the checkpoint script) and you would also have to kill the player before changing the Value in leaderstats (in the skipping script).

No it doesn’t allow you to do that. Say you get to stage 3, you can not decrease the number nor have your spawn set there if it was below 3, I basically know nothing about lua scripting so I’m probably going to have to figure that one out.

Well, then I’m almost sure the problem is in your checkpoint script. I can help you in Private Messages or in here, it is probably your choice. You can also make a new topic for that.
Have a great rest of the day!

Use purchasingPlayer:LoadCharacter() for respawn

2 Likes

That’s a great idea! How didn’t I think about that… It will be better, but it still won’t solve the issue with checkpoints. Thank you for correcting me!

2 Likes