You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I am attempting to make a system in which when a player clicks a button in the workspace next to a mannequin, a function will be called and they will be prompted to purchase the item that the mannequin is seen wearing in the workspace. There are two parameters of the function, the player who clicked the button, and the asset id of the item. The asset id of what I’d like the player to buy is in an IntValue inside of each mannequin model, with the value of the IntValue being set to the asset id of the shirt. There is more than you can understand by reading the code below.
What is the issue? Basically what’s going on is when I click the button, it does not prompt me to purchase the item and instead an error is outputted that says “Argument 2 is missing or nil”.
What solutions have you tried so far? Well, I’ve tried to fix the issue myself in Studio for the past hour or so, but didn’t have any luck. I’ve tried using :WaitForChild() on the IntValue, getting it’s value with tostring() and some different things, too. When you read the code, the whole idea of what I’m making is a little bit inefficient. I’m a pretty good scripter, and am making this as a little project to sharpen my knowledge in certain areas of Roblox Lua.
I should also mention that there are three mannequins, and I tried it on a random one of the three and the errors were on line 18 and 26.
This is the code:
local marketplaceService = game:GetService("MarketplaceService") local mannequins = script.Parent local m1 = mannequins.M1 local m2 = mannequins.M2 local m3 = mannequins.M3 local m1ClickDetector = m1.BuyShirt.ClickDetector local m2ClickDetector = m2.BuyShirt.ClickDetector local m3ClickDetector = m3.BuyShirt.ClickDetector local m1ClothingId = m1.AssetId.Value local m2ClothingId = m2.AssetId.Value local m3ClothingId = m3.AssetId.Value local function purchaseClothingItem(player,clothingid) marketplaceService:PromptProductPurchase(player,clothingid) end m1ClickDetector.MouseClick:Connect(function(playerClicked1,m1ClothingId) purchaseClothingItem(playerClicked1,m1ClothingId) end) m2ClickDetector.MouseClick:Connect(function(playerClicked2,m2ClothingId) purchaseClothingItem(playerClicked2,m2ClothingId) end) m3ClickDetector.MouseClick:Connect(function(playerClicked3,m3ClothingId) purchaseClothingItem(playerClicked3,m3ClothingId) end)