So, this script. It is a server side script in the Workspace. I do not know how to debug test it as I am now allowed (apparently) in start server/player and play solo. Can't see the output of the script, I don't even know if it activates. But basically, click a gui and buy a gamepass (gamepass 19186931) so I assume that activates this function? So it SHOULD start.. But what's stopping it?
local MarketplaceService = Game:GetService("MarketplaceService") local productId = 19186931 local ds = game:GetService("DataStoreService"):GetDataStore("ContinueButton") MarketplaceService.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == productId then local asynccode = receiptInfo.PlayerId .. "buys" if ds:GetAsync(asynccode) == nil then ds:SetAsync(asynccode, 0) end local numberBought = ds:IncrementAsync(asynccode, 1) print("Player bought the continue developer product. Player now has "..GetAsync(asynccode) .. " buys.") currentplr = GetPlayerById(receiptInfo.PlayerId) gui = currentplr.PlayerGui gui.continuegame.Disabled = false return Enum.ProductPurchaseDecision.PurchaseGranted end end function GetPlayerById(id) for _,v in ipairs(game.Players:GetPlayers())do if(v.userId==id)then return(v) end end return(nil) end
You're calling GetPlayerById on line 14, but you didn't define the function until line 23. You're going to get the error "attempt to call global 'GetPlayerById' (a nil value)". You should move the GetPlayerId function before your function for handling purchases.
On line 12 you use GetAsync without supplying the instance you're calling it on. The fixed line should be:
print("Player bought the continue developer product. Player now has "..ds:GetAsync(asynccode) .. " buys.")