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

Why Doesn't My Door that Checks the Colors of Two Buttons Open?

My aim is to create a system in which when both buttons have been clicked on and are green, clicking on the door will cause it to become transparent and unable to be collided with, "opening" it. Specifically, the two buttons start off red, and the player clicking on them turns them green; this part works fine, the door does not. In my code, I check whether the door is already transparent/uncollidable, and if it is not, then it checks if the buttons are green. If so, it will turn the door transparent/uncollidable; if not, it will remain opaque. Behold:

local door = game.Workspace.ButtonPuzzle.DoorObject.DoorUnion
local buttonOne = game.Workspace.ButtonPuzzle.Button1.ClickableButton1
local buttonTwo = game.Workspace.ButtonPuzzle.Button2.ClickableButton2

game.Workspace.ClickDetectorDoor.OnServerEvent:Connect(function()

	if door.Transparency == 0 and door.CanCollide == true then
		if buttonTwo.BrickColor == "Parsley green" and buttonOne.BrickColor == "Parsley green" then
			door.Transparency = 1
			door.CanCollide = false
		else
			
		end	
	else
		door.Transparency = 0
		door.CanCollide = true
	end
end)

Whenever I run this code, despite both buttons being green, the door does not "open". When I removed the if statement checking for green, it allowed me to "open" and "close" the door. What am I doing wrong? Thank you

1 answer

✓ Accepted answer

add .Name onto the Brickcolor property, see if that works.

Example:

buttonOne.BrickColor.Name == "Color here"

3 comments

0

Yes, it worked! Thank you so much :)

0

No problem, your defining the name of a Color so remember that!

0

Khosraux, if it helped you should really put VAHMPIN's awsner as the awsner. As a way of thanking VAHMPIN for helping you :=)

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