Problems with disconnecting a function

local function CheckButtonClick()
	local connection
	for i, button in pairs(CarList) do	-- Go through all the buttons and check if one has been clicked
		connection = button.Activated:Connect(function()

Whenever the same button is pressed more than once, it prints “a” multiple times, I would think I should be disconnecting the function but I’ve no clue why it’s not working exactly.

Oh wow never mind, after reading this post I realized I didn’t even need to call this as a local function from UserInputService.

I’ll keep the post up for anyone else with the problem though.