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
6 years ago
1game.Players.PlayerAdded:Connect(function(plr)
2    if game.MarketplaceService:PlayerOwnsAsset(plr, 5397071) then
3        print("Success, player has asset.")
4    else
5        print("Player doesn't own this asset.")
6    end
7end)

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 — 6y
0
GamePassService method is broken and outdated now. User#19524 175 — 6y
0
looking at the page of the asset associated with the id, it's not a gamepass Rare_tendo 3000 — 6y

2 answers

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

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

Wiki: Roblox Wiki Page - UserOwnsGamePassAsync()

You can use this script:

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

Hope it helped!

Ad
Log in to vote
0
Answered by
NorteX_tv 101
6 years ago
Edited 6 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 — 6y

Answer this question