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?
✓ ANSWER ACCEPTED
Tool which check if certain player have got a certain item in the inventory. Is that possible?
1 answer
✓ Accepted answer
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
