Attempting to Create a System Between Bricks via . BrickColor

I am attempting to create a ‘system’ between four parts, with three playing the role as ‘activators’ and the fourth as a ‘final activator’.

The three blocks run off individual events; Touched, MouseClick, MouseHover, and all work as intended. When each event has taken place, the block lights up green. The only issue I am facing is the response from the fourth and final block that appropriately evaluates the signals between the three activators.

As an indicator between the three block’s eligibility to make the fourth turn green, the script inside of the fourth block searches; -and prints when each block has turned green, individually. While I am almost positive my coding is correct, I believe the issue lies between me connecting "A/B/C.BrickColor == “Sea green”, or the ‘if’ statements are triggering too-soon, before the blocks actually turn green Thank you

a = game.Workspace.A
b = game.Workspace.B
c = game.Workspace.C

wait(15)
print("Attempting to call..")

if a.BrickColor.new == "Sea green" then
	print("1 SUCCESS")
end

if b.BrickColor == "Sea green" then
	print("2 SUCCESS")
	
	if c.BrickColor == "Sea green" then
		print("3 SUCCESS")
		script.Parent.BrickColor = BrickColor.new ("Sea green")
	end
end

type or paste code here

U should move your if statements into a function and call it when one of the parts’ color is changed, also you can make them as one if statement. I’ll invert the if statements and stop the function when the condition is met (originally when condition is not met).

local a = game.Workspace.A
local b = game.Workspace.B
local c = game.Workspace.C

local function onColorChange()
	if a.BrickColor ~= "Sea green" then return end -- 1st if, but inverted
	if b.BrickColor ~= "Sea green" then return end -- 2nd if, but inverted
	if c.BrickColor ~= "Sea green" then return end -- 3rd if, but inverted

	print("Success") -- Remove later

	script.Parent.BrickColor = BrickColor.new("Sea green")
end

a:GetPropertyChangedSignal("Color"):Connect(onColorChange)
b:GetPropertyChangedSignal("Color"):Connect(onColorChange)
c:GetPropertyChangedSignal("Color"):Connect(onColorChange)

Unfortunately, even with personal modifications this did not fire. Though, I have managed to get the fourth block to turn green, may you please help me with my ‘if’ statements so that they go in chronological order, and the fourth only turns after all have turned green? Thank you.

local a = game.Workspace.A
local b = game.Workspace.B
local c = game.Workspace.C


local function onCall()
	if a.BrickColor ~= "Sea green" then
		print("It is sea green")
		
	end
	
	if b.BrickColor ~= "Sea green" then
		print("It is also sea green")
		
	end
	
	if c.BrickColor ~= "Sea green" then
		print("It is finally sea green")
		
		end
	end



a:GetPropertyChangedSignal("Color"):Connect(onCall)
b:GetPropertyChangedSignal("Color"):Connect(onCall)
c:GetPropertyChangedSignal("Color"):Connect(onCall)

Sorry, I forgot to include the fourth block. It would just be script.Parent.BrickColor = BrickColor.new("Sea green)

1 Like

The function I gave u checks all of their colors and only turns the 4th block green if the 3 are, what’s the problem?

1 Like

‘new’ is not a valid member of BrickColor, which i’m assuming does not allow the rest of the script to fire.

1 Like

then just remove the new? If you mean BrickColor.new(), you only use it if you want to change the BrickColor

1 Like

he made an error. use BrickColor.Name
It’s worth noting that ~= means they are NOT equal. So the color would NOT be “Sea Green” so it “returns” which means it stops the function and returns no value.

1 Like

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