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

Why does my script prompt a decal purchase instead of a clothes purchase?

In my game I want to script a buying prompt where a player can buy clothes off of a mannequin. I have everything set up for the script to work, but for some reason when I test buying clothes outside of studio on the published game, it would always return "this item is not currently for sale." The image is never of the full item but the decal that the item was based on. I don't know why the script sees my assets as decals instead of clothes. Also, the script can never load in the ImageID, and I don't know why. Help?!?

this script would load in the info from the clothes to a gui

OpenItemCard = game.ReplicatedStorage:WaitForChild("OpenItemCard")

function OpenItemCard.OnClientInvoke(ID,Body,ItemType,GroupType)

	local Asset = game:GetService("MarketplaceService"):GetProductInfo(ID)
	
	local InfoBox = Card.InfoBox
	local ReXxInfoBox = Card.ReXxInfoBox
	local OutletInfoBox = Card.OutletInfoBox
	
 	local Price = tostring(Asset.PriceInRobux)
	local ImageID = tostring(Asset.IconImageAssetId)
	
	local function GetItemInfo()
		Card.InfoBox.Header.ItemName.Text = Asset.Name
		Card.ReXxInfoBox.Header.ItemName.Text = Asset.Name
		Card.OutletInfoBox.Header.ItemName.Text = Asset.Name
		Card.Price.Text = Price.."R$"
		Card.ItemImage.Image = ImageID
		Card.Creator.Text = Asset.Creator.Name
		Card.ItemInfo.Text = Asset.Description 
		print("Gathered Item Info for Card: "..Asset.Name)

	end

end

	local function TransferID()
		Card.ID.Value = ID
		print("Transferred Clothing ID: "..ID)
	end

script inside the mannequin

Adornee = script.Parent.Parent.Parent.AdorneeAnchor
ID = string.sub(script.Parent.Parent.Parent.Body.Shirt.ShirtTemplate, 14) -- change if it does not fit the correct type of clothing
ItemType = 1 --(1 for shirts, 2 for pants)
GroupType = 1 --(1 for ReXx Studios, 2 for ReXx Outlet, 3 for Other)
script.Parent.MouseClick:Connect(function(plr)
	print("Click Detected")
	game.ReplicatedStorage.OpenItemCard:InvokeClient(plr, ID, Adornee, ItemType, GroupType)
	print("ItemCard Loaded")
end)

Script inside the ImageButton

script.Parent.MouseButton1Click:connect(function()
	local ID = script.Parent.Parent.Parent.ID.Value
	local player = game.Players.LocalPlayer
	game:GetService("MarketplaceService"):PromptPurchase(player,ID)
end)

2 comments

0

Is the script inside the image button local?

0

@incapaz That wouldn't cause the problem they are having.

1 answer

✓ Accepted answer

That's because the Shirt/Pants template is not the shirt displayed on the catalog. It's actually the web template that was used to create the shirt, hence why that issue keeps popping up. The best way around this is to store the ID as a Integer value inside the same location where the shirt is and use that instead.

Mannequin Script:

Adornee = script.Parent.Parent.Parent.AdorneeAnchor
ID = script.Parent.Parent.Parent.Body.Shirt.Id.Value -- Make sure to create an IntValue named 'Id' in the correct location!
ItemType = 1 --(1 for shirts, 2 for pants)
GroupType = 1 --(1 for ReXx Studios, 2 for ReXx Outlet, 3 for Other)
script.Parent.MouseClick:Connect(function(plr)
    print("Click Detected")
    game.ReplicatedStorage.OpenItemCard:InvokeClient(plr, ID, Adornee, ItemType, GroupType)
    print("ItemCard Loaded")
end)

12 comments

0

which ID would I use then? This script is supposed to automatically get the ID of the shirt and before I took the ID out of the shirtTemplate using string.sub, so what would I do to get the right ID? The same thing but in an IntValue?

0

The problem you're having is that it's prompting the template correct? If it is, store the shirt shown in the catalog as the ID, so that it will prompt the right thing, and not the template.

0

The script is not prompting the whole template. I used string.sub so the script could index to the ShirtTemplate, then take out 'rbxassetid://' and only get the ID out of it. And this script works, the ID gets sent to my GUI and the GUI takes the ID and gathers information from it. I just need to know which ID can get me the actual shirt and not just an image of the template.

0

i also need to know how to get the script to automatically take the correct ID out from a shirt so it can be sent to my GUI.

0

Oh, I see what you mean. Send "rbxassetid://"..Id.Value, so that it concatenates rbxassetid with the ID, and then use string.sub() on the client side inside of PromptPurchase so that it prompts just the ID.

0

still does the same thing :/

0

Did you set Id.Value to the ID of the shirt, not the number that came out of the Shirt's ShirtTemplate?

0

Okay I did, and now I'm getting the info I needed. The unresolved issue is that I need to figure out a way to do this automatically instead of manually. Is there any way I can find the ID of the actual shirt through a script instead of doing it by hand?

0

Unfortunately, not. I agree the situation is a mess and I am also trying to find a way to get it automatically. The only way to get the web template of the shirt or pants is by dropping it into a shirt/pants/decal object, although this doesn't work with scripting.

0

Well. That ruins everything. Thanks for the help though I appreciate it.

0

Yep, sorry for the inconvenience. Now that I think about it actually, there could be an HTTP proxy that does it automatically. If you want you could do some research.

0

I'll look into it, thanks again

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