Game pass button not working

Hello! I am currently trying to make a button that only performs an action if the player has a game pass.

script.Parent.MouseButton1Click:connect(function()
   if game:GetService("MarketplaceService"):UserOwnsGamePassASync(9043064) then
		script.Parent.Parent.Parent.Colors.Visible = false
		script.Parent.Parent.Parent.FaceList.Visible = false
		script.Parent.Parent.Parent.HatsList.Visible = false
		script.Parent.Parent.Parent.ShirtList.Visible = false
		script.Parent.Parent.Parent.PantsList.Visible = false
		script.Parent.Parent.Parent.Egg2008.Visible = true
		script.Parent.Parent.Parent.Egg2010.Visible = false
		script.Parent.Parent.Parent.SpecialMenu.Visible = false
   end
end
)

The “9043064” is the game pass ID.The script is a LocalScript that outputs " [ UserOwnsGamePassASync is not a valid member of MarketplaceService]". The button also does not perform the action even though I own the game pass.


I hope this thread isn’t to short or lacking enough information. I just couldn’t think of anything else to put.

1 Like

I can point out two mistakes on your script. The first one that causes the error is that the function doesn’t exist. Remember that Lua is case sensitive. The function UserOwnsGamePassASync doesn’t exist, but UserOwnsGamePassAsync does.

The second mistake is on the arguments. As per the documentation, you forgot to put one more argument which is the UserId.

Here’s a script that should work:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
   if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 9043064) then
		script.Parent.Parent.Parent.Colors.Visible = false
		script.Parent.Parent.Parent.FaceList.Visible = false
		script.Parent.Parent.Parent.HatsList.Visible = false
		script.Parent.Parent.Parent.ShirtList.Visible = false
		script.Parent.Parent.Parent.PantsList.Visible = false
		script.Parent.Parent.Parent.Egg2008.Visible = true
		script.Parent.Parent.Parent.Egg2010.Visible = false
		script.Parent.Parent.Parent.SpecialMenu.Visible = false
   end
end
)
3 Likes

I can confirm that MarketplaceService can be accessed using a local script.

I just tested the function myself :slight_smile:

I stand corrected, I just checked the spelling aha. My server script was written by myself hence why I haven’t got an error (capitalization muscle memory :laughing: ).

I’m not talking about you standing corrected. Your point was that UserOwnsGamePassAsync() does not work within local script, but you’re wrong. You can call UseOwnsGamePassAsync() within a local script. Yes, I tested it myself on Roblox Studio.

If you’d like to continue, please message me on slothfulGuy#5064 on Discord.