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?
COMMUNITY QUESTION
If I am to make a pair of pants how would I make it give a custom item in game?
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Tysm