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

If I am to make a pair of pants how would I make it give a custom item in game?

I have a pair of Pants that if purchased I want the buyer to get a custom item in said game. How would I do this?

1 answer

You want to use MarketPlaceService to accomplish this. There is a method within MarketPlaceService, called PlayerOwnsAsset, which allows the person to check if a player owns an asset (such as pants in your case).

local ASSET_ID = XXXXXXXXXX -- Replace with your pants id
 
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
 
Players.PlayerAdded:Connect(function (player)
	local success, doesPlayerOwnAsset = pcall(PlayerOwnsAsset, MarketplaceService, player, ASSET_ID)
	if success and doesPlayerOwnAsset then
		-- Give the player the item
	elseif not success then
		warn(doesPlayerOwnAsset) -- Print the error
	else
		-- Player simply does not own the pants/asset.
		print("The player doesn't own the asset.")
	end
end)

1 comment

0

Tysm

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