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

Nil value when trying to sell clothes?

Asked by 7 years ago
Edited 7 years ago

I found a script and model that sells clothes, and i tried changing it to how i need it to work and something is wrong. Basically i'm trying to get it to buy the clothes once you press a gui button.

local Buy = script.Parent
local ITEM_ID = 887227764  -- Here put the ID of the clothes you want to sell

Buy.MouseButton1Click:Connect(Clicked)
game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

You don't have the event set up correctly

local Buy = script.Parent
local ITEM_ID = 887227764  -- Here put the ID of the clothes you want to sell

Buy.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptPurchase(p,ITEM_ID)
end)

Im guessing p is the player and Buy is the button

0
"MarketplaceService:PromptPurchase() player should be of type Player, but is of type nil" do you know how to fix this? Sniper2458 11 — 7y
0
@Sniper2458 did you set p as the player? if not, local p = game.Players.LocalPlayer , if this is a localscript DanzLua 2879 — 7y
0
This worked, thank you very much! Sniper2458 11 — 7y
Ad

Answer this question