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

How come this buy prompt still shows up no matter what?

I am currently working on this script where the gamepass buy prompt only shows up when you've pressed the button w/o having the gamepass. Problem is, the gamepass prompt still shows up, even when I do own the gamepass, and the frame I'm attempting to make visible, does not.

Here's my script:

local GamePassService = game:GetService("GamePassService")
local MarketService = game:GetService("MarketplaceService")
script.Parent.MouseButton1Down:Connect(function()
	
	local plr = game.Players.LocalPlayer
	
   if GamePassService:PlayerHasPass(plr,4984362) then
          script.Parent.Parent["Jukebox Frame"].Visible = true
   else 
        MarketService:PromptGamePassPurchase(plr, 4984362)
   end
	
end)

2 comments

0

It could possibly be due to if you're testing this in studio. Try publishing the game and trying it on the actual game instead of studio.

0

My button just flat-out stops working in the game.

1 answer

###The PlayerHasPass method is server-side only, and is broken due to the new game pass update. You should be using MarketplaceService:UserOwnsGamePassAsync() method instead.

local MarketService = game:GetService("MarketplaceService")

script.Parent.Activated:Connect(function(inputObject)

   if MarketService:UserOwnsGamePassAsync(plr.UserId,4984362) then
          script.Parent.Parent["Jukebox Frame"].Visible = true
   else 
        MarketService:PromptGamePassPurchase(plr, 4984362)
   end
end)

5 comments

0

^ Do what he says, except change Activated to MouseButton1Click.

0

^ Do what he says, except change Activated to MouseButton1Click.

0

why

0

It makes no difference whether it's "Activated" or you use "MouseButton1Click" because either way, you're 'Activating' the button.

0

Activated is compatible for mobile / console devices.

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