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

Is there a way to get the number of a limited item that a player owns?

Asked by 4 years ago

Can't seem to find anything online about this. Kind of an odd question tho so I'm not too surprised.

1 answer

Log in to vote
1
Answered by 4 years ago

Alright, So, we need a PlayerOwnsAsset, Ill just give you the finished script, You should learn about PlayerOwnsAsset tho!

local Item_ID = 98253626 -- the item i wish i had and i really want it lol

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, item_ID)
    if not success then
        print("Well this script does not know if "..player.Name.." Has "..item_ID)
        print(success, dosePlayerOwnAsset)
    elseif success then
        if doesPlayerOwnAsset == true then -- if he has it
        print(player.Name.." Has the item with the id of "..item_ID
        print(success, dosePlayerOwnAsset)
        elseif dosePlayerOwnAsset == false then -- if he dose not have it
        print(player.Name.." Dosen't have the item with the id of "..item_ID
        print(success, dosePlayerOwnAsset)
    end
end
end
end)

Alright, See you next time! :D also you may remove the success if you don't want it to scan if its correct or not, Just saying you should keep it, ALSO I might not have made the correct placing but you can mess with it!, Also not tested xD

0
I figured out a way to get what I needed using the Inventory API. This only checks if the player owns a specific asset. I was trying to get the quantity of a limited item the player owns. JJBIoxxer 50 — 4y
Ad

Answer this question