Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gamepass Script not working properly?

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 comment

1 answer

✓ Accepted answer

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)

1 comment

0

Unfortunately none of them work.

This discussion is preserved as it was. New answers, comments, and votes are closed.