When I try to use this script, it warns Argument 1 missing or nil for line 15, which is warn(response). This is my full script.
local MarketplaceService = game:GetService("MarketplaceService")
local GetProductInfo = MarketplaceService.GetProductInfo
local debounce = false
MarketplaceService.ProcessReceipt = function(purchaseInfo)
local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
if purchaseInfo.ProductId == 1167909680 and debounce == false then
debounce = true
print("24 HOUR ADVERT bought.")
local ID = tonumber(plr.PlayerGui.AdGui.Frame.TextBox.Text)
local success,response = pcall(GetProductInfo,MarketplaceService,ID)
if success then
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = "rbxassetid://"..response.IconImageAssetId
else
warn(response) -- Line 15 here.
end
wait(1)
debounce = false
elseif purchaseInfo.ProductId == 1167909777 and debounce == false then
debounce = true
print("THREE DAY ADVERT bought.")
wait(1)
debounce = false
elseif purchaseInfo.ProductId == 1167909888 and debounce == false then
debounce = true
print("30 DAY ADVERT bought.")
wait(1)
debounce = false
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local success, response = pcall(function()
MarketplaceService:GetProductInfo(ID)
end)
if success then
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = "rbxassetid://"..response.IconImageAssetId
else
warn(response)
end
If you are changing the text of the text box inside the client, it won’t work. The server is not able to detect the text so you can use a RemoteEvent. Fire the event from the local script. The server script will get it and change the text.
This may be because of the change of text inside the client. If so, the server is not able to detect it.
Text labels’ or text boxs’ texts are “Label” by default. The children of the StarterGui gets replicated into the PlayerGui. The server is not responsible for that folder anymore. This is why you should RemoteEvent to manage the events between the client and the server.
And the reason it returns a nil value, you use tonumber(). As I explained above, by default, the text box’s text is “Label” and when you use tonumber(), it tries to convert string to number, but it contains a letter.
You sent the location of the box and the server will equate the text of the box to written ID number in client. So the new text is now the product ID for the both server and client.