Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to show a part when the baseplate changes color?

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.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.