Script Acting Weird Today

i am trying to make a brick that turns black when clicked and if it is black it will turn white when clicked.
i also wanted it to change a variable named “Number1” it is currently equal to 0.
so when the brick is black i want the number to be 1 and if it’s white it changes to 0.
it’s for a pattern which is equal to 0,1,0,1
and at the bottom of the script it checks if the player’s pattern is the same as that.
the script has no errors but still functions weird. when it is white it turns white when it is black it turns white i fixed that but now it only turns black
the number changes to 1 if its white and doesn’t even change to 0.
when i fixed the issue with the color it broke the number more since it now doesn’t even change.

quick recap of the problem:
-color only stays black
-number does not change.

script:

Part1.ClickDetector.MouseClick:Connect(function(plr)--Part1 = script.Parent.Part1
	if Part1.Color == Color3.new(255,255,255) then--Color For White
		Number1 = 1
		print(Number1)
		Part1.Color = Color3.new(0,0,0)--Black
	else
		Part1.Color = Color3.new(255,255,255)--White
		Number1 = 0
		print(Number1)
	end
end)

try Number1.Value

can you send a photo of explorer

strong text

but it is a variable not a numberValue
in the script it’s like Local Number1 = 0

oh okay then, i thought it was a numbervalue

send a photo of explorer if possible please

Try this:


Part1.ClickDetector.MouseClick:Connect(function(plr)--Part1 = script.Parent.Part1
	if Part1.Color == Color3.new(255,255,255) then--Color For White
		Number1 = 1
		print(Number1)
		Part1.Color = Color3.fromRGB(0,0,0)--Black
	else
		Part1.Color = Color3.fromRGB(255,255,255)--White
		Number1 = 0
		print(Number1)
	end
end)

why is the solution from rgb? i don’t understand what the difference is between new and fromrgb

color3.new returns a rgb color value
And color3.fromRGB returns a color value from an rgb value

1 Like

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