How could I make a door open and close at certain times?

  1. What do you want to achieve? Keep it simple and clear!
    I want a door to open at a certain time with ClockTime in Lighting. For example if the ClockTime is 8 then the door will open and will stay open but if the ClockTime is 19 then it will close and stay closed until the ClockTime is 8.

  2. What is the issue? Include screenshots / videos if possible!
    Above

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to figure out how to make a script from YouTube and the DevForum but I still can’t find anything.

2 Likes

Try this, for the door script use Tween Service or just setting the CFrame of the door to open and close

local DoorOpened = false --Debounce

    while wait() do
    	if game.Lighting.ClockTime == 8 and DoorOpened == false then
    		DoorOpened = true -- Setting the debounce so door script doesnt run again
    		
    		--Door open script
    	elseif game.Lighting.ClockTime == 19 and DoorOpened == true then
    		DoorOpened = false -- allowing the script to open the door again once its 8
    		--Door close script
    	end
    end
2 Likes

This is probably a Script located inside of the door, right?

yes, you could put it into a module script but that’s more advanced, making the door script shouldn’t be hard, I suggest watching this video and editing a little code to make it only open when the Clock Time is right

1 Like