Me and my friend @3Escot are making a system to detect if a player has the “Doge” hat. And then to give them the rank. (Join game > check for hat > rank)
I have seen a group do this (Crown of Ooowners - Roblox)
How would we do this?
local players = game:GetService("Players")
local marketplace = game:GetService("MarketplaceService")
local playerOwnsAsset = marketplace.PlayerOwnsAsset
local function hasAsset(player, assetId, maxTries)
maxTries = maxTries or 5
if maxTries == 0 then return end
maxTries -= 1
local success, result = pcall(playerOwnsAsset, marketplace, player, assetId)
if success then
if result then
return true
else
return false
end
else
warn(result)
task.wait()
hasAsset(player, assetId, maxTries)
end
end
local function onPlayerAdded(player)
local hasDoge = hasAsset(player, 151784320)
print(hasDoge) --false
end
players.PlayerAdded:Connect(onPlayerAdded)
This will work for any asset but I’ve used the doge accessory’s asset ID to showcase. For me, hasDoge is false as I do not own the doge hat.