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

Gamepass Script not working properly?

Asked by 6 years ago

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 \\
06local id1 = 4657110
07 
08 
09 
10 
11-- // Extra Freight Gamepass \\
12 
13game.Players.PlayerAdded:connect(function(player)
14    if game:GetService("GamePassService"):PlayerHasPass(player, id1) then
15script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
View all 22 lines...

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

PlayerHasPass() doesn't always work. You should use functions of MarketplaceService such as UserOwnsGamePassAsync or PlayerOwnsAsset (with the assetid of the gamepass).

1local id1 = 4657110
2 
3game.Players.PlayerAdded:connect(function(player)
4    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id1) then
5        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
6    else
7        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned"
8    end
9end)

Or

1local id1 = 1934332928 --the assetid
2 
3game.Players.PlayerAdded:connect(function(player)
4    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player.UserId, id1) then
5        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
6    else
7        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned"
8    end
9end)
0
Unfortunately none of them work. CarlPlandog 20 — 6y
Ad

Answer this question