Need help with connecting function in shop script

Alright, so I have a shop script and I’m trying to make a function that fires a different event depending on which button was pressed, but I’m getting Players.CodedCrystal.PlayerGui.ShopGUI.ShopScript:75: Expected ')' (to close '(' at column 60), got '(' - Studio - ShopScript:75
I’m not quite sure where this extra ‘)’ is supposed to go and I’m pretty lost

Here’s the full code just incase something else is causing this

local repStorage = game:GetService("ReplicatedStorage")
local ClickDetector = workspace.ShopNPC.ClickDetector
local ShopEvents = repStorage.ShopEvents
local ShopGUI = script.Parent
local CloseButton = ShopGUI.CloseButton
local ShopFrame = ShopGUI.ShopFrame
local PowerUpFrame = ShopFrame.PowerUpFrame
local WeaponFrame = nil
local AbilityFrame = nil
local SpeedFolder = PowerUpFrame.Speed
local AttackFolder = PowerUpFrame.Attack
local HealthFolder = PowerUpFrame.Health
local EventsTable = {
	speed = ShopEvents.buySpeed1,
	speed2 = ShopEvents.buySpeed2,
	speed3 = ShopEvents.buySpeed3,
	attack = nil,
	attack2 = nil,
	attack3 = nil,
	health = ShopEvents.buyHealth1,
	health2 = ShopEvents.buyHealth2,
	health3 = ShopEvents.buyHealth3
}
local ButtonsTable = {
	BuySpeed = SpeedFolder.BuySpeedOne,
	BuySpeed2 = SpeedFolder.BuySpeedTwo,
	BuySpeed3 = SpeedFolder.BuySpeedThree,
	BuyAttack = nil,
	BuyAttack2 = nil,
	BuyAttack3 = nil,
	BuyHealth = HealthFolder.BuyHealthOne,
	BuyHealth2 = HealthFolder.BuyHealthTwo,
	BuyHealth3 = HealthFolder.BuyHealthThree
}
local debounce = false

-- Opening the shop
ClickDetector.MouseClick:Connect(function()
	if ShopGUI.Enabled == true then
		return 0
	end
	ShopGUI.Enabled = true
	WeaponFrame.Enabled = true
	PowerUpFrame.Enabled = false
	AbilityFrame.Enabled = false
end)

-- Setting up buying functions
local function BuySpeed(event)
	if debounce then
		return 0
	end
	event:FireServer()
	debounce = true
	wait(1)
	debounce = false
end

local function BuyHealth(event)
	if debounce then
		return 0
	end
	event:FireServer()
	debounce = true
	wait(1)
	debounce = false
end

-- Other button functions
CloseButton.MouseButton1Click:Connect(function()
	ShopFrame.Visible = false
end)

-- All bought events
ButtonsTable["BuySpeed"].MouseButton1Click:Connect(function(BuySpeed(EventsTable["speed"]))
end)

I know there’s an answer to this somewhere as I already had to fix this once, and my dad was able to find something, but I have no idea what the thing was called, or what I would look up for this specific issue.

You forgot to add a ) on this line

ButtonsTable["BuySpeed"].MouseButton1Click:Connect(function(BuySpeed(EventsTable["speed"]))

Change it to this

ButtonsTable["BuySpeed"].MouseButton1Click:Connect(function(BuySpeed(EventsTable["speed"])))


It tells me to put in the “end” at the end even if I add the extra parentheses, and I get the same thing no matter if the “end” has a parenthese on the end of it or not, I’m not quite sure what’s incomplete about the function.

Change the last lines to this perhaps?

-- All bought events
ButtonsTable["BuySpeed"].MouseButton1Click:Connect(function()
	BuySpeed(EventsTable["speed"])
end)

Bingo. I remember now lol, the function is supposed to just be “function()” instead of having buyspeed inside of it. Thanks!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like

Oh I will most likely be making plenty more especially when I try to make my own weapons lol.

1 Like