Hello, I got this code from Roblox’s code sample, but this code doesn’t seem to work. I have the script inside the TextButton. The error prints out the player should be a type of a player, but is a type of a nill.
Is there a way to fix this? Thank you.
This is the script that I got from Roblox’s code sample. Also, I added script.Parent.MouseButton1Click:Connect(promptPurchase).
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local productID = -- My developer product id
-- Function to prompt purchase of the developer product
local function promptPurchase()
local player = Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, productID)
end
script.Parent.MouseButton1Click:Connect(promptPurchase)
Also, I have a question, if I don’t script for the receipt, will I not get the Robux that player bought?
To prompt a purchase it must be a server script but to check when the button is locked you must use a local script if the button is on GUI.
So you will then need to use a remote event to connect the local script to the server script.