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

Changing colors of a door indicator?

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

✓ Accepted answer
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!

4 comments

0

I changed the script but now my door opens stays open and the color doesnt change .                                                                                                                                                                     

0

Are there any errors in the output?

0

If indicatorlight is in the door model then use “game.Workspace.Corridor.KeyCardDoor.indicatorlight.Color = BrickColor.Green() “

0

^ Forgot to add that part. Thanks

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