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