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 5 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

-- Gamepasses Script 
-- Written by CarlPIandog


-- // Variables \\
local id1 = 4657110




-- // Extra Freight Gamepass \\

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id1) then 
script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
    else
script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned"
    end
end)

-- // Gamepass \\
--Paste above and change ids etc

1 answer

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

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

local id1 = 4657110

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id1) then
        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
    else
        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned"
    end
end)

Or

local id1 = 1934332928 --the assetid

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player.UserId, id1) then
        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Owned"
    else
        script.Parent.ExtraFreightOwned.Text = "Extra Freight: Not Owned"
    end
end)
0
Unfortunately none of them work. CarlPlandog 20 — 5y
Ad

Answer this question