local MarketPlaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remotes = ReplicatedStorage.Remotes local TweenGui = require(script.Parent.TweenGui) local Player = Players.LocalPlayer local PlayerGui = Player.PlayerGui local Gui = PlayerGui:WaitForChild("Shop") local Frame = Gui.Frame local OpenButton = PlayerGui:WaitForChild("Main").Right.Shop local ExitButton = Frame.Exit local Container = Frame.Container local Template = Container.Template local GamepassIDS = { 1222392383, 1221912385, 1209923362 } local function PromptGamepass(GamepassID: number, Buy: TextButton) local OwnsPass = false local Success, ErrorMessage = pcall(function() OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) end) if not Success then return end if OwnsPass then Buy.Price.Text = "Owned" Buy.Active = false Buy.AutoButtonColor = false else Buy.Active = true Buy.AutoButtonColor = true MarketPlaceService:PromptGamePassPurchase(Player, GamepassID) end end local function GenerateGamepasses() for _, GamepassID in GamepassIDS do local OwnsPass = false local Success, ErrorMessage = pcall(function() OwnsPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) end) local GamepassInfo = MarketPlaceService:GetProductInfo(GamepassID, Enum.InfoType.GamePass) local ClonedTempate = Template:Clone() ClonedTempate.Name = GamepassInfo.Name ClonedTempate.Icon.Image = `rbxassetid://{GamepassInfo.IconImageAssetId}` ClonedTempate.Buy.Price.Text = `{GamepassInfo.PriceInRobux} R$` ClonedTempate.Visible = true ClonedTempate.ID.Value = GamepassID ClonedTempate.Parent = Container if OwnsPass then ClonedTempate.Buy.Price.Text = "Owned" ClonedTempate.Buy.Active = false ClonedTempate.Buy.AutoButtonColor = false else ClonedTempate.Buy.Active = true ClonedTempate.Buy.AutoButtonColor = true end ClonedTempate.Buy.MouseButton1Click:Connect(function() PromptGamepass(GamepassID, ClonedTempate.Buy) end) end end local function GamePassPurchased(GamepassID) for _, v in Container:GetChildren() do if v:FindFirstChild("ID") then if v.ID.Value == GamepassID then ClonedTempate.Buy.Price.Text = "Owned" ClonedTempate.Buy.Active = false ClonedTempate.Buy.AutoButtonColor = false break end end end end OpenButton.MouseButton1Click:Connect(function() if Gui.Enabled == true then TweenGui.CloseGui(Gui, Frame) else TweenGui.OpenGui(Gui, Frame) end end) ExitButton.MouseButton1Click:Connect(function() TweenGui.CloseGui(Gui, Frame) end) Remotes.GamePassPurchased.OnClientEvent:Connect(GamePassPurchased) GenerateGamepasses()