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

Changing colors of a door indicator?

Asked by 5 years ago

I have a question on how to change the color of a part while my door is open and the turn back to normal when the door closes.

This is what I already have to open/close the door and it works but I want to add in a line that changes the color of a part names:"indicatorlight" to turn green when the door is open and red when the door is closed.

script.Parent.Touched:Connect(function(hit)
    if hit.Parent.Name == "KeyCard" then

        game.Workspace.Corridor.KeyCardDoor.CanCollide = false
        game.Workspace.Corridor.KeyCardDoor.Transparency = 1
        wait(2.5)
        game.Workspace.Corridor.KeyCardDoor.CanCollide = true
        game.Workspace.Corridor.KeyCardDoor.Transparency = 0

    end
end)

Please help.

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
script.Parent.Touched:Connect(function(hit)
debounce = false --Prevents the door being opened whilst its already open.
if hit.Parent.Name == "KeyCard" then
  if debounce == false then
    debounce = true
    game.Workspace.Corridor.KeyCardDoor.CanCollide = false
    game.Workspace.Corridor.KeyCardDoor.Transparency = 1
    game.Workspace.Corridor.KeyCardDoor.Color = BrickColor.Green() 
    wait(2.5)
    game.Workspace.Corridor.KeyCardDoor.CanCollide = true
    game.Workspace.Corridor.KeyCardDoor.Color = BrickColor.Red()
    game.Workspace.Corridor.KeyCardDoor.Transparency = 0
    wait()
    debounce = false
  end
end
end)

If this helped, don't forget to accept the answer!

0
I changed the script but now my door opens stays open and the color doesnt change .                                                                                                                                                                      simgamer1 2 — 5y
0
Are there any errors in the output? xXTouchOfFrostXx 125 — 5y
0
If indicatorlight is in the door model then use “game.Workspace.Corridor.KeyCardDoor.indicatorlight.Color = BrickColor.Green() “ ABK2017 406 — 5y
0
^ Forgot to add that part. Thanks xXTouchOfFrostXx 125 — 5y
Ad

Answer this question