For loop isn't running

I want to achieve a working function that slightly alters the main color of the GUI for its stroke so the stroke seems a bit darker, the issue is that after trying out a lot I came to find out that the for loop I had been using isn’t running at all, meaning that also print statements are not printing as already said that the loop is not running and I do not know why it does that.

Function:

local function GetStroke(MainColor)
	local ColorTable = {
		R = MainColor.R*255,G = MainColor.G*255,B = MainColor.B*255
	}
	for Index,Value in ipairs(ColorTable) do
		local NewValue = Value - 125
		if NewValue < 0 then
			NewValue = 0
		elseif NewValue > 255 then
			NewValue = 255
		end
		print(NewValue)
		ColorTable[Index] = NewValue
		print(ColorTable[Index])
	end
	print(ColorTable)
	return Color3.fromRGB(ColorTable.R,ColorTable.G,ColorTable.B)
end

ipairs only loops through integer indexes in ascending order. Your table has string indexes only. Try using pairs instead.

1 Like