Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i cant get to do a click to buy?

this is what i have, and can you maybe make it so it will give an item to the player when bought

function onClicked(p)
local CD = script.Parent
local ITEM_ID = 689063033

local Click = Instance.new("ClickDetector",CD)

game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

local Click = Instance.new("ClickDetector")

2 answers

local CD = script.Parent
local ITEM_ID = 689063033
local Click = Instance.new("ClickDetector",CD)

function onClicked(p)

game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)
end


script.Parent.ClickDetector.MouseClick:connect(onClicked)

It seems you have made an instance for the ClickDetector, but have not set a parent, by making an Instance your second parameter will be where you want to parent it.

function onClicked(playerWhoClicked)
	local CD = script.Parent
	local ITEM_ID = 689063033
	local Click = Instance.new("ClickDetector",CD) -- not sure why you need this, but I'll leave it in anyway

		game:GetService("MarketplaceService"):PromptPurchase(playerWhoClicked, ITEM_ID)
	end
end

local ClickDetector = Instance.new('ClickDetector', script.Parent)

ClickDetector.MouseClick:Connect(onClicked)

2 comments

0

it does not work

This discussion is preserved as it was. New answers, comments, and votes are closed.