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.
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.
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:
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)
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.
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
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].