Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool which check if certain player have got a certain item in the inventory. Is that possible?

Asked by 6 years ago

I need some help with a tool I'm making. When a player equip the tool a GUI will be visible with a text box. Enter a username in the text box and you can see if the player have a certain item/shirt in the inventory. Is that possible?

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

This should work if you put it in a local script, assuming you mean an item in their actual inventory and not an in-game item.

local ms = game:GetService("MarketplaceService")
local textbox = --enter directory to textbox
local assetId = --enter id of shirt/item

textbox.FocusLost:Connect(function(enterPressed)
   if enterPressed then
       local plr = game.Players:FindFirstChild(textbox.Text)
       if plr then
          if ms:PlayerOwnsAsset(plr,assetId) then
             --do stuff when player does own the asset
          else
              --do stuff when the player doesn't own the asset
          end
       end
   end
end)

Keep in mind you may want to check if the player owns the asset on the server instead for security.

Ad

Answer this question