so I need to detect if player has a t-shirt in there inventory, any help? I need like: if player has (the t shirt) then (I'll add code here) else (I'll add more code here)
COMMUNITY QUESTION
I need to find a t-shirt in the local players inv?
1 answer
Use this for the client
local mps= game:GetService("MarketplaceService")
local id = 0123456789 -- t shirt id here
local lplr = game.LocalPlayer
local check = mps:PlayerOwnsAsset(lplr,id)
if check == true then
print(lplr.Name.." owns asset : "..mps:GetProductInfoAsync(id))-- change this to what you want if they own it
else
print(lplr.Name.." does not own asset : "..mps:GetProductInfoAsync(id).." prompting purchase."
mps:PromptPurchase(lplr,id)
end
And this for the server
local mps= game:GetService("MarketplaceService")
local id = 0123456789 -- t shirt id here
game.Players.PlayerAdded:Connect(function(plr) -- fires when new player joins
local check = mps:PlayerOwnsAsset(plr,id)
if check == true then
print(plr.Name.." owns asset : "..mps:GetProductInfoAsync(id))-- change this to what you want if they own it
else
print(plr.Name.." does not own asset : "..mps:GetProductInfoAsync(id).." prompting purchase."
mps:PromptPurchase(plr,id)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Pair 'FindFirstChild' with a conditional statement.