if game.Workspace.Baseplate.BrickColor=BrickColor.new("Really red") true then
print(Changed to transparency)-- To see if the script worked. game.Workspace.Part.Transparency = 0
end
if game.Workspace.Baseplate.BrickColor=BrickColor.new("Sea green" true then
print(Changed transparency)-- To see if the script worked. game.Workspace.Part.Transparency = 1
end
--Hide part when the Baseplate is green Show when the Baseplate is red.
Here's one that should work:
local baseplate = game.Workspace.Baseplate baseplate:GetPropertyChangedSignal("BrickColor"):Connect(function() local part = game.Workspace.Part if baseplate.BrickColor == BrickColor.new("Really red") then print("Changed to transparency") part.Transparency = 0 elseif baseplate.BrickColor == BrickColor.new("Sea green") then print("Changed transparency") part.Transparency = 1 end end)
What we're doing here is listening for when the BrickColor
property of baseplate
changes value. when it does we check with an if
statement to see if it's "Really Red". If it is, we change the transparency to 0; if it isn't we check with an elseif
statement to see if it's "Sea green".
If it is, we change the transparency to 1; if it isn't, nothing happens.
Why your script didn't work
if game.Workspace.Baseplate.BrickColor=BrickColor.new("Really red") true then print(Changed to transparency)-- To see if the script worked. game.Workspace.Part.Transparency = 0 end if game.Workspace.Baseplate.BrickColor=BrickColor.new("Sea green" true then print(Changed transparency)-- To see if the script worked. game.Workspace.Part.Transparency = 1 end
Well, this script will run immediately when the game starts up. This is not right, because it will check if the BrickColor
is "Really red" and that's not what we want. The same thing happens with the other if
statement. We fixed that by connecting it to an event listener.
Another mistake is checking with =
sign. If you want to set a value, you use =
, but if you want to check for a value you use ==
. That's two equal signs.
I hope I could help and that you learned something from this.
Closed as Not Constructive by hiimgoodpack and BashGuy10
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?