Hello, so I have a problem. I’m making a game, and when you join, the gamepass shop is open. (Without toggling it with the open/close button) I don’t know scripting very well, and I tried using the Destroy function, but it destroyed the whole UI. Please help if someone could!
Script:
local Gamepasses = {Gamepass_Name_Here, Gamepass_Name_Here}
local Player = game.Players.LocalPlayer
local MarketplaceService = game:GetService(“MarketplaceService”)
local GamepassFrame = script.Parent.GamepassesFrame
local SampleFrame = GamepassFrame.SampleFrame
local ToggleButton = script.Parent.ToggleButton
function toggleShopGUI()
if GamepassFrame.Visible == false then
GamepassFrame.Visible = true
ToggleButton.Text = “Close”
else
GamepassFrame.Visible = false
ToggleButton.Text = “Gamepass Shop”
end
end
function setupGamepasses()
for i = 1, #Gamepasses do
local GamepassId = Gamepasses[i]
local GamepassData = MarketplaceService:GetProductInfo(GamepassId, Enum.InfoType.GamePass)
local GamepassPrice = GamepassData.PriceInRobux
local GamepassIcon = GamepassData.IconImageAssetId
local GamepassSlot = SampleFrame:Clone()
local GamepassImage = GamepassSlot.GamepassImage
local PurchaseButton = GamepassSlot.Purchase
GamepassSlot.Parent = GamepassFrame
GamepassSlot.Name = GamepassId
PurchaseButton.Text = "Purchase - $R " .. GamepassPrice
GamepassImage.Image = "rbxassetid://" .. GamepassIcon
PurchaseButton.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(Player, GamepassId)
end)
end
SampleFrame:Destroy()
end
ToggleButton.MouseButton1Click:Connect(function()
toggleShopGUI()
end)
setupGamepasses()