for i, v in pairs(script.Parent:GetChildren()) do if v:IsA("TextButton") or v:IsA("ImageButton") then -- Makes sure it is a button if v:FindFirstChild("Id") then -- Makes sure that there is 'Id' inside text label if v.Id.Value > 0 then -- Makes sure there is an id in 'Id' v.MouseButton1Click:Connect(function() game.MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, v.Id.Value) -- Prompts the player to purchase the gamepass end) end end end end
repeat wait() until game.Players.LocalPlayer.Character -- Yields until our character is loaded
while wait() do local magnitude = (game.Players.LocalPlayer.Character.PrimaryPart.Position - game.Workspace.Shop.Hitbox.Position).Magnitude if magnitude <= 11.5 then -- Max magnitude script.Parent.Visible = true else script.Parent.Visible = false end end
And in the dev console it says
Players.ELPEQUENOIKER.PlayerGui.Main.MainFrame.GemsShop.LocalScript:16:attempt to index nil with "Position" Stack Begin Script "Players.ELPEQUENOIKER.PlayerGui.Main.MainFrame.GemsShop.LocalScript", Line 16