UI Button Help [SERIOUS]

Hello, so I made a gamepass shop and for some reason one of my buttons isn’t working.

I have it setup like this, all the images in “13413131” are for shadows under buy buttons.
For some reason the first buy button which is Rainbow Name Gamepass isn’t working but all others are? I have the “13413131” images in ColorChangingGamepassFrame, which is Rainbow Name Gamepass, but when I click it when I run the server nothing happens.
image

Issue: https://gyazo.com/d2de342a90dd55c6e352ba0765fdb2ec

1 Like

Some questions to consider while debugging:

  • Is there any errors in the DevConsole?
  • Is the ID of your Product correct?
  • Do you already own it? (thus it won’t prompt)

I don’t own anything, and nothing is in the console, lastly the IDs are right I checked.

A few things that we need to help you:

  • While your script appears to work, I’d still like to have a look at it, as it’s the most likely issue here.
  • Could you show the url of the gamepass that’s not working.

@DataErased If you own a gamepass, it will still prompt with a “You already own this, your account hasn’t been charged” message, so the issue has to be in the prompting.

Example

e5fd5ae0ef800b29c18ed88fb993fdfd50f9c354
Source from another developer forums post

Edit: I see your point, nevermind.

local MarketplaceService = game:GetService("MarketplaceService")

local roundBg1 = script.Parent.Parent:WaitForChild("Test1")
local roundBg2 = script.Parent.Parent:WaitForChild("test2")
local roundBg3 = script.Parent.Parent:WaitForChild("test3")
local txtbutton = script.Parent.Parent.CloseShop
local MainFrame = script.Parent
local VipGamepass = MainFrame.VipGamepassFrame.Buy
local ColorChangeNameGamepass = MainFrame.ColorChangeGamepassFrame.Buy3
local JetskiGamepass = MainFrame.JetskiGamepassFrame.Buy5
local PetFishGamepass = MainFrame.PetFishTrailGamepassFrame.Buy6
local RedTrailGamepass = MainFrame.RedTrailGamepassFrame.Buy8
local SubmarineGamepass = MainFrame.SubmarineGamepassFrame.Buy9
local SurfboardGamepass = MainFrame.SurfboardsGamepassFrame.Buy10
local OpenShop = MainFrame.Parent.OpenShop

local player = game.Players.LocalPlayer

local VipGamepassId = 4811928
local ColorChangeNameGamepassId = 5283084
local JetskiGamepassId = 4934981
local PetFishGamepassId = 5312626
local RedTrailGamepassId = 5182395
local SubmarineGamepassId = 6212971
local SurfboardGamepassId = 5242168



VipGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, VipGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, VipGamepassId)
		end
	end)

	ColorChangeNameGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, ColorChangeNameGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, ColorChangeNameGamepassId)
		end
	end)

	JetskiGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, JetskiGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, JetskiGamepassId)
		end
	end)
	PetFishGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, PetFishGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, PetFishGamepassId)
		end
	end)
	
	RedTrailGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, RedTrailGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, RedTrailGamepassId)
		end
	end)
	SubmarineGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, SubmarineGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, SubmarineGamepassId)
		end
	end)
	SurfboardGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, SurfboardGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, SurfboardGamepassId)
		end
	end)
		
txtbutton.Visible = false
	MainFrame.Visible = false
	roundBg1.Visible = false
	roundBg2.Visible = false
	roundBg3.Visible = false

OpenShop.MouseButton1Down:Connect(function()
	--MainFrame.Visible = not MainFrame.Visible
	--txtbutton.Visible = not txtbutton.Visible
	MainFrame.Visible = true
	txtbutton.Visible = true
	MainFrame.Visible = true
	roundBg1.Visible = true
	roundBg2.Visible = true
	roundBg3.Visible = true
end)

@ThatTimothy, I thought he might’ve had an if statement in his code to prevent the pop-up from happening if he already owned the gamepass (via UserOwnsGamepassAsync), which leads me to request the same thing you did:

1 Like

Well, I do but it still prompts you if you have it. Either way I dont have it and it isnt working.

The first thing I’m going to do is parse out the required segment for testing:

RedTrailGamepass.MouseButton1Down:Connect(function()
    local hasPass = false --Just in case
	local success, message = pcall(function()
	    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, RedTrailGamepassId)	
    end)

    if not success then
        warn('Error!!! ' .. message)
    end
	
	if hasPass == true then
		print("Player has pass")
	else
        MarketplaceService:PromptGamePassPurchase(player, RedTrailGamepassId)
	end
end)

Every button works expect the ChangeNameGamepass one which is the first one on the left of the scrolling frame.

Maybe the button variable for ChangeNameGamepass is linked to the wrong thing?

I agree with @DataErased. Try this code segment in place of the current one and tell me the output:

RedTrailGamepass.MouseButton1Down:Connect(function()
   print(1234567890)
   local hasPass = false --Just in case
   local success, message = pcall(function()
       hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, RedTrailGamepassId)	
   end)

   if not success then
       warn('Error!!! ' .. message)
   end
   
   if hasPass == true then
   	print("Player has pass")
   else
       MarketplaceService:PromptGamePassPurchase(player, RedTrailGamepassId)
   end
end)

What should happen is you see ‘1234567890’ in the output. If you don’t, there’s the issue.

Already tried all that, I don’t think it is a script issue. Idk the issue though.

Its not for the red trail though. Its for the colorchanging one.

Still is not working, and nothing in the output.

But the gamepass you linked is the id of the RedTrail? Did you mix them up?

No it isnt? I checked and everything the gamepass I linked is the color changing name? nvm, wrong gamepass. it is this one.

Ok, so that makes more sense. I was confused because:

local ColorChangeNameGamepassId = 5283084
local RedTrailGamepassId = 5182395
https://www.roblox.com/game-pass/5182395/Rainbow-Trail

But this does work:
https://www.roblox.com/game-pass/5283084/Rainbow-Nametag

Alright, here’s what you should try:

ColorChangeNameGamepass.MouseButton1Down:Connect(function()
    print('Click yay')
    local hasPass = false
	local success, message = pcall(function()
	    hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, ColorChangeNameGamepassId)	
    end)
	
	if hasPass == true then
		print("Player has pass")
	else 
       MarketplaceService:PromptGamePassPurchase(player, ColorChangeNameGamepassId)
	end
end)

My bet is that your button is not defined to what you think it is. Try clicking all the buttons until it outputs.

You have it defined as ColorChangingFrame.Buy3, when the image shows the button being ColorChangingFrame[13413131].

That doesn’t make sense though, because in my script i define it to buy3, not the images.

I’m talking about this image:
image

Does anything ouput after you replaced the code segment? Because if nothing does, I’m likely right.