Need Help With Shop Script

I am trying to make a shop script for my game and something keeps happening.

Basically it allows the player to buy one of two game-passes that I created, Corgi Head Plushy, and VIP.

The Local Script

local MarketplaceService = game:GetService("MarketplaceService")

local MainFrame = script.Parent.MainFrame
local VipButton = MainFrame.Gamepass.TextButton
local CorgiHeadButton = MainFrame.Item.TextButton
local OpenShop = script.Parent.OpenShop

local player = game.Players.LocalPlayer

local VipGamepass = 12424604

VipGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
		hasPass = MarketplaceService.UserOwnsGamePassAsync(player.UserId, VipGamepass)
	end)
	
	if hasPass then
		print("Player Already Has VIP Gamepass")
	else
		MarketplaceService:PromptGamePassPurchase(player, VipGamepass)
	end
end)

local CorgiHeadPlushyGamepass = 12981668

CorgiHeadPlushyGamepass.MouseButton1Down:Connect(function()
	local success, message = pcall(function()
		hasPass = MarketplaceService.UserOwnsGamePassAsync(player.UserId, CorgiHeadPlushyGamepass)
	end)
	
	if hasPass then
		print("Player Already Has VIP Gamepass")
	else
		MarketplaceService:PromptGamePassPurchase(player, CorgiHeadPlushyGamepass)
	end
end)

OpenShop.MouseButton1Down:Connect(function()
	MainFrame.Visible = not MainFrame.Visible
end)

The Server-Side Script:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

-----------------------------------------------------------------

local VipGamepass = 12424604

game.Players.PlayerAdded:Connect(function(player)
	
	local success, message = pcall(function()
		hasPass = MarketplaceService.UserOwnsGamePassAsync(player.UserId, VipGamepass)
	end)
	
	if hasPass == true then
		print("Player Has The Gamepass")
	end
end)

-----------------------------------------------------------------

local CorgiHeadPlushyGamepass = 12981668

game.Players.PlayerAdded:Connect(function(player)

	local success, message = pcall(function()
		hasPass = MarketplaceService.UserOwnsGamePassAsync(player.UserId, VipGamepass)
	end)

	if hasPass then
		print("Player Has The Gamepass")
		
		local CorgiHead = game.ReplicatedStorage["Corgi Head"]:Clone()
		CorgiHead.Parent = player.Backpack
	end
end)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
	if purchaseSuccess == true and purchasedPassID == CorgiHeadPlushyGamepass then
		print(player.Name .. " Purchased The Gamepass")
		
		local CorgiHead = game.ReplicatedStorage["Corgi Head"]:Clone()
		CorgiHead.Parent = player.Backpack
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(onPromptGamePassPurchaseFinished)

Errors It is giving:
Players.AidanPlaysYT_Real.PlayerGui.ShopGUI.LocalScript:12: attempt to index number with ‘MouseButton1Click’

14:59:11.672 - ServerScriptService.ShopScript:46: Expected ‘end’ (to close ‘function’ at column 59), got

you need to use a GuiObject/Button in this line, you can’t click to a number variable, can you?

you don’t need to add function() here just call the function name.

1 Like