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

What's wrong with my skip stage script? --i know hardly anything about scripting.

Asked by 6 years ago

The "xxxxxxxx" is my dev product that the user buys to skip a stage. This script works in Studio but not my game. I'm really confused as to why.

If anyone can help, that'd be great thanks.

> 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 == xxxxxxxx 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
0
I'm not at all sure but on line 11 you use the index "userId" which is normally "UserId". This could easily be causing the script to error. k1nq 30 — 6y
0
I'm basically just spamming your question at this point, but it could also be because there is no wait and the server has no time to actually load in the leaderstats etc, try making a simple wait of a value such as 3 at the beginning of the script and then go about testing it. k1nq 30 — 6y
0
Fixed UserId, Entered a wait for (3). neither worked. souI_taker 0 — 6y
0
Funny thing is, it was working in earlier version of the game. I don't know what i did to it, but i think i may have to revert back like 12 hours of work into the past just to fix this dumb problem lmfao souI_taker 0 — 6y

Answer this question