Tool shop not working

  1. What do you want to achieve? Keep it simple and clear!
    A working tool shop

  2. What is the issue? Include screenshots / videos if possible!
    The shop is not working and there’s an error saying "Attempt to connect failed: Passed value is not a function " Which I don’t know what it means and how to fix it.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Searching for solution but still can’t find

Here’s a local script which is in the shop gui

local open = game.Workspace.PartShop.PartShopPad
local close = game.Workspace.PartShop.PartShopTele

local Part8x8 = script.Parent.ScrollingFrame.Part8x8.TextButton
local Part16x8 = script.Parent.ScrollingFrame.Part16x8.TextButton
local Part24x8 = script.Parent.ScrollingFrame.Part24x8.TextButton 
local Truss = script.Parent.ScrollingFrame.Truss.TextButton

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool")

local function OpenShop(Parts)
	local ply = game.Players:FindFirstChild(Parts.Parent.Name)
	if ply then
		ply.PlayerGui.PartsShop.Enabled = true
		ply.Character.Humanoid.WalkSpeed = 0
	end
end

local function CloseShop()
	local ply = game.Players.LocalPlayer
	ply.PlayerGui.PartsShop.Enabled = false
	ply.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X,close.Position.Y + 3,close.Position.Z)
	ply.Character.Humanoid.WalkSpeed = 16
end

local function BuyTool8x8()
	local tool = ReplicatedStorage.ShopItem.Part8x8
	remoteEvent:FireServer(tool)
end

local function BuyTool16x8()
	local tool = ReplicatedStorage.ShopItem.Part16x8
	remoteEvent:FireServer(tool)
end

local function BuyTool24x8()
	local tool = ReplicatedStorage.ShopItem.Part24x8
	remoteEvent:FireServer(tool)
end

local function BuyToolTruss()
	local tool = ReplicatedStorage.ShopItem.TrussPart
	remoteEvent:FireServer(tool)
end

open.Touched:Connect(OpenShop)
script.Parent.Close.MouseButton1Click:Connect(CloseShop)

Part8x8.MouseButton1Click:Connect(BuyTool8x8)
Part16x8.MouseButton1Click:Connect(BuyTool16x8)
Part24x8.MouseButton1Click:Connect(BuyTool24x8)
Truss.MouseButton1Click:Connect(BuyToolTruss)

Here’s the server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool")

local function BuyTool(player, tool)
	local giveTool = ReplicatedStorage.ShopItem[tool.Name]:Clone()
	giveTool.Parent = player.Backpack
end

remoteEvent.OnServerEvent:Connect()

On what line is this occurring, providing the full error message helps us help you.

Nevertheless you are using :Connect incorrectly.

Part8x8.MouseButton1Click:Connect(function(BuyTool8x8) end)

That is the proper usage.

When hooking up :Connect() functions to external functions, you must pass in the function you want to hook up as an argument of your :Connect() function. In your server script, you did not do that on the last line, where you call the OnServerEvent function.

Try the following code instead in your server script.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool")

local function BuyTool(player, tool)
	local giveTool = ReplicatedStorage.ShopItem[tool.Name]:Clone()
	giveTool.Parent = player.Backpack
end

remoteEvent.OnServerEvent:Connect(BuyTool)

Also, what @DouglasRastelli said is ironically correct and incorrect. While you did use :Connect() incorrectly it was not for your MouseButton1Click functions, but rather for your OnServerEvent function. Your MouseButton1Click function implementation looks correct.

Hope this helps. Let me know if you have any further issues.

remoteEvent.OnServerEvent:Connect()

This is where your issue arises, you’re calling the connection method through an event signal listener but not actually connecting any callback function to the event.

That would be incorrect use of :Connect(), you need only pass the name of the defined function itself as an argument to the connection method in order to connect a callback function to any given event. If you want to connect an anonymous/lambda function on the other hand you’ll need to explicitly define the function using the reserved function keyword inside the parentheses of the call to :Connect().