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
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)
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.