Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

4 comments

0

killerbrenden is there another more easier way then having to do every single hat?

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.

0

Okay thanks

0

If this helped you or cleared up any confusion, feel free to select it as an answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.