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

If Player Has Bough GamePass/Developer Product To Get A Tool?

Asked by 6 years ago

If Player has game Pass, When Joins Server To Have A Specific Tool, I Tried but it doesn't work!

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local gamePassID = 440994981  -- Change this to your game pass ID
05 
06function 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 
View all 34 lines...

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Try this..

Be sure to capitalize Connect and Clone, and we also changed PlayerSpawned to PlayerAdded, because PlayerSpawned does not work.

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local gamePassID = 440994981 -- Change this to your game pass ID
05 
06function 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 
View all 28 lines...
Ad
Log in to vote
0
Answered by 6 years ago

I see your problem, you never made it clear that the players hasPass is true or not. Use this script instead:

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local gamePassID = 440994981  -- Change this to your game pass ID
05 
06function 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 
View all 31 lines...
Log in to vote
0
Answered by 6 years ago

I see your problem, you never made it clear that the players hasPass is true or not. Use this script instead:

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local gamePassID = 440994981  -- Change this to your game pass ID
05 
06function 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 
View all 31 lines...

Answer this question