If Player has game Pass, When Joins Server To Have A Specific Tool, I Tried but it doesn't work!
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local gamePassID = 440994981 -- Change this to your game pass ID |
05 |
06 | function onPlayerSpawned(player) |
07 |
08 | local hasPass = false |
09 |
10 | -- Check if the player already owns the game pass |
11 | local success, message = pcall ( function () |
12 | hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) |
13 | print ( "Has Game Pass for Gun" ) |
14 | end ) |
15 |
Try this..
Be sure to capitalize Connect and Clone, and we also changed PlayerSpawned to PlayerAdded, because PlayerSpawned does not work.
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local gamePassID = 440994981 -- Change this to your game pass ID |
05 |
06 | function onPlayerSpawned(player) |
07 |
08 | local hasPass = false |
09 |
10 | -- Check if the player already owns the game pass |
11 | local success, message = pcall ( function () |
12 | hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) |
13 | print ( "Has Game Pass for Gun" ) |
14 | end ) |
15 |
I see your problem, you never made it clear that the players hasPass is true or not. Use this script instead:
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local gamePassID = 440994981 -- Change this to your game pass ID |
05 |
06 | function onPlayerSpawned(player) |
07 |
08 | local hasPass = false |
09 |
10 | -- Check if the player already owns the game pass |
11 | local success, message = pcall ( function () |
12 | hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) |
13 | hasPass = true |
14 | end ) |
15 |
I see your problem, you never made it clear that the players hasPass is true or not. Use this script instead:
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local gamePassID = 440994981 -- Change this to your game pass ID |
05 |
06 | function onPlayerSpawned(player) |
07 |
08 | local hasPass = false |
09 |
10 | -- Check if the player already owns the game pass |
11 | local success, message = pcall ( function () |
12 | hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) |
13 | hasPass = true |
14 | end ) |
15 |