Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
VAHMPIN 277 Moderation Voter
3 years ago
Edited 3 years ago

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

Example:

buttonOne.BrickColor.Name == "Color here"
0
Yes, it worked! Thank you so much :) Khosraux 2 — 3y
0
No problem, your defining the name of a Color so remember that! VAHMPIN 277 — 3y
0
Khosraux, if it helped you should really put VAHMPIN's awsner as the awsner. As a way of thanking VAHMPIN for helping you :=) Skydoeskey 108 — 3y
Ad

Answer this question