Attempt to call a number value

I keep getting the attempt to call a number value error. The error only occurs when I try to run the function more than once. Any help is appreciated!

for i, v in pairs(allHalos)do
	local clone = template:Clone()
	clone.Name = v.Name
	clone.ImageLabel.ImageColor3 = v.Color
	if checkRequirement(v.Name) then
		clone.Status.Text = "Unlocked"
	else
		clone.Status.Text = "Locked"
	end
	clone.Title.Text = v.Name
	clone.Position = UDim2.new(.05 + ((i-1)%2)*.45,0, .025+ math.floor((i-1)/2)*.225,0)
	clone.TextButton.MouseButton1Down:Connect(function()
		selectedHalo(i) -- error is here!
	end)
	clone.Parent = template.Parent
	v.ShopView = clone
	clone.Visible = true
end

What is selectedHalo? As the error says, it is probably a number, are you setting it anywhere in your code?

oof. I just looked at all the instances of selectedHalo, my function and variable were named the same. Thank you so much for your help!

1 Like