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

What's wrong with this has asset check? It doesn't detect if player has asset.

Asked by
NorteX_tv 101
5 years ago
game.Players.PlayerAdded:Connect(function(plr)
    if game.MarketplaceService:PlayerOwnsAsset(plr, 5397071) then
        print("Success, player has asset.")
    else
        print("Player doesn't own this asset.")
    end
end)

Problem is it prints "Player doesn't own this asset" even when a player does have an asset. I made sure ID is correct. (Do not check what is there :P)

0
That's because it's a gamepass id, not asset id. You need to either use GamePassService:PlayerHasPass() or MarketplaceService:UserOwnsGamePassAsync() Amiaa16 3227 — 5y
0
GamePassService method is broken and outdated now. User#19524 175 — 5y
0
looking at the page of the asset associated with the id, it's not a gamepass Rare_tendo 3000 — 5y

2 answers

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

PlayerOwnsAsset() not work, you need to use UserOwnsGamePassAsync()

Wiki: Roblox Wiki Page - UserOwnsGamePassAsync()

You can use this script:


local id = 5397071 -- Id of your gamepass game:GetService("Players").PlayerAdded:Connect(function(plr) print(plr.Name .. " joined") if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then print("Success, player has asset.") else print("Player doesn't own this asset.") end end)

Hope it helped!

Ad
Log in to vote
0
Answered by
NorteX_tv 101
5 years ago
Edited 5 years ago

Weird thing, if I type: roblox.com/game-pass/5397071 is not equal to roblox.com/catalog/5397071, it's different things! In 1 there is some awful shirt, in 1 my gamepass. Weird. Anyways, I must check it.

0
CATALOG = Item, GAME-PASS = gamepasses yHasteeD 1819 — 5y

Answer this question