I want that if the player has the gamepass it makes the gamepass button disappear.
Here is my script.
Local Script:
local Player = game.Players.LocalPlayer
local Button = script.Parent
local MarketPlaceService = game:GetService("MarketplaceService")
local PassId = --Nevermindthis--
if MarketPlaceService:UserOwnsGamePassAsync(Player,PassId) then
Button.Visible = false
end
Button.MouseButton1Click:Connect(function()
MarketPlaceService:PromptGamePassPurchase(Player, PassId)
end)
Try this maybe?, Because your checking if the player owns the Gamepass when they join (The script starts running) but not when they click the button.
Button.MouseButton1Click:Connect(function()
MarketPlaceService:PromptGamePassPurchase(Player, PassId)
if MarketPlaceService:UserOwnsGamePassAsync(Player,PassId) then
Button.Visible = false
end
end)