Color changing to black?

I am trying to to make a redo button and it changes the color back to what it was before. However the part is going black.

Local script:

local colour = moves[_-(v+1)]
print(colour)--prints 1, 0.105882, 0.121569
moves[_-i].Color = Color3.new(moves[_-(v+1)])--part goes black

Any ideas why?

I’m pretty unfamiliar with the underscores in the moves[], but moves[_-(v+1)] is making the color 3 negative I think, which would make it 0,0,0.

Color3.new() will return default values 0,0,0 → black. Must be how you’re storing the value in the table?

moves is a table, the underscore is a interger and so is v

Edit: it’s just getting the value from table

what’s the type of colour? if it’s a color3, then the issue is that you’re pretty much doing Color3.new( Color3.new(...) ). you’d just use Moves[…] as the color in that case

Its a colour3 value

Its from a backgroundcolor3 of a part

so you’d set moves[_-i].Color to moves[_-(v+1)] instead of wrapping the Color3 inside a Color3.new

1 Like

Now the color doesn’t even change.

what does your code look like now?

local colour = moves[_-(v+1)]
print(colour)--prints 1, 0.105882, 0.121569
moves[_-i].Color = colour--doesnt change colour?

heres the table:
image

there’s no Color3 in that table, and your [5] = 0.498039, 0.105882, 1, is actually causing this instead

[1] = 0.105882,
[2] = 1,
[3] = Part,
[4] = Part,
[5] = 0.498039,
[6] = Part,
[7] = Part,
[8] = Part,
[9] = Part,
[10] = 4

hm? but if I print

print(typeof(colour))

I get Color3?
image

are you sure [_-i] is correct? you’re using v in the same code

Yes, I created a fill tool that fills it and when I click redo they all go black so I’m positive that its correct

during this, what color is it expected to change to? (1, 0.105, 0.121) is pretty much red
image

Ah yes this is also what confused me. It is not meant to be red but when I did
image
it was red.

here’s the whole function

redo.MouseButton1Down:Connect(function()
	print(moves)
	for _,v in pairs(moves)do
		if _==#moves then
			local tp = typeof(v)
			if tp ~= "number" then
				v:Destroy()
				moves[_]=nil
			else
				for i = 1,v do
					local colour = moves[_-(v+1)]
					print(colour)--prints 1, 0.105882, 0.121569
					moves[_-i].Color = colour--part goes black
					
				end
				for i = 1,v do
					moves[_-i] = nil
				end
				
				moves[_-1] = nil
				moves[_] = nil
				moves[#moves] = nil
				print(moves)
			end
			
		end
	end
end)

usually, you’d use _ as a placeholder if you don’t need it. you should use index, i, key, or k instead
could I see what the output is showing when you click once?

also, v is short for value

ye I was using it as placeholder then I changed how I was going to use the function and didn’t go back and I know what they stand for. But here is the output on one click:
image
-first table is what is started with

-second table values of the ones that were filled with the amount at end and colour at start

-third print is just the colour

-fourth table is after wiping colour value stuff since they should have changed colours

ok, your [5] looks fine
I thought that was a screenshot of your script earlier