I have a problem scripting a gamepass script. It's a script which basically sets a text in a player's gui to see if they have the script or not. It doesn't work for some reason
01 | -- Gamepasses Script |
02 | -- Written by CarlPIandog |
03 |
04 |
05 | -- // Variables \\ |
06 | local id 1 = 4657110 |
07 |
08 |
09 |
10 |
11 | -- // Extra Freight Gamepass \\ |
12 |
13 | game.Players.PlayerAdded:connect( function (player) |
14 | if game:GetService( "GamePassService" ):PlayerHasPass(player, id 1 ) then |
15 | script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned" |
PlayerHasPass()
doesn't always work. You should use functions of MarketplaceService
such as UserOwnsGamePassAsync
or PlayerOwnsAsset
(with the assetid of the gamepass).
1 | local id 1 = 4657110 |
2 |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | if game:GetService( "MarketplaceService" ):UserOwnsGamePassAsync(player.UserId, id 1 ) then |
5 | script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned" |
6 | else |
7 | script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned" |
8 | end |
9 | end ) |
Or
1 | local id 1 = 1934332928 --the assetid |
2 |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | if game:GetService( "MarketplaceService" ):PlayerOwnsAsset(player.UserId, id 1 ) then |
5 | script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned" |
6 | else |
7 | script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned" |
8 | end |
9 | end ) |