Why is this underlined red?

THIS IS AN EXAMPLE CODE. THAT’S NOT THE ACTUAL CODE

local TableOfStuff = {
	Var1 = workspace:WaitForChild("Part1"),
	Var2 = workspace:WaitForChild("Part2"),
	Var3 = workspace:WaitForChild("Part3"),
	Var4 = workspace:WaitForChild("Part4"),
	Var5 = workspace:WaitForChild("Part5")
}


button.MouseButton1Click:Connect(function()
	if 1 == 1 then
		local randomCahance = math.random(1, #TableOfStuff)
	end
end)

Why is #TableOfStuff underlined red? Doesn’t # get the length of a table?

1 Like

it might be because this is a dictionary. The index are not numbers and therefore the length will be 0. math.random(1, 0) will obviously not work.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.