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

How do I get player information as in inventory? If i can

Asked by 4 years ago
Edited 4 years ago

So sounds confusing but ill try to explain. So i want to make a leader board of how many hats that player has. So what im trying to get at is are you able to sync players hats from there inventory and turning it into a LeaderStat thing. If need more info just say or go to my twitter @evthehuman https://twitter.com/evthehuman

1 answer

Log in to vote
0
Answered by 4 years ago

MarketPlaceService - As of the Service that handles player assets, I would assume there isn't a function. Unless, you want to create a variable for every Hat ID there is in a table and check if the player owns that hat, but that's pretty much a mess and memory consuming, as there are plenty of hats.


Example:

local marketPlaceService = game:GetService("MarketplaceService")

local possibleHats = {"Hat1_ID","Hat2_ID","Hat3_ID","And So On"}

game.Players.PlayerAdded:Connect(function(player)
    for _,hat in pairs(possibleHats) do
        if marketPlaceService:PlayerOwnsAsset(hat) then
            local hatsValue = player:WaitForChild("leaderstats"):FindFirstChild("Hats")
            hatsValue.Value = hatsValue + 1
            print("Player Owns Hat")
        end
    end
end)

Hope this gave you an understanding of why this is a hassle and why you wouldn't be able to do this so easily.

~killerbrenden

0
killerbrenden is there another more easier way then having to do every single hat? ExoticTwix 15 — 4y
0
Not that I know of, because if you read the MarketPlaceService, which handles player assets, there's not function or event that you can tell if a player owns ALL hats besides doing each individual one separately. killerbrenden 1537 — 4y
0
Okay thanks ExoticTwix 15 — 4y
0
If this helped you or cleared up any confusion, feel free to select it as an answer. killerbrenden 1537 — 4y
Ad

Answer this question