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

i cant get to do a click to buy?

Asked by
DJH_100 28
5 years ago

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)

0
local Click = Instance.new("ClickDetector") lon233bcc 31 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
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)
Ad
Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

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)
0
it does not work DJH_100 28 — 5y

Answer this question