Currently making a prison in a game. I am wanting to make the doors open and unopen at certain times and it closing at them.
I have tried this script.
Local GameTime = Game.Script.TimeScript
When game.Time.12:00:00 = true then
if game.Time.12:00:00 = false do
game.Workspace.Door1(function(destroy) = false
When game.Time.17:00:00 = true then
game.Workspace.Door1(function(create) = true
if game.Time.17:00:00 = false do
game.Workspace.Door1(function(create) = false
So, this is pretty hard to do but I am really having difficulties making this script.
Does anyone know how this system works? I am starting to feel like I cannot do this. I know some prison games have this system but I just don’t know how they do it.
local Lighting = game:GetService(“Lighting”)
local Hour = 12
local Mins = 0
local Night = script.Night.Value – I used a BoolValue called ‘Night’
Mins = Mins + 1
if Mins >= 60 then
Mins = 0
Hour = Hour + 1
if Lighting.ClockTime >= 18 or Lighting.ClockTime < 6 then
if Night == false then
Night = true
--- Put your code here
elseif Lighting.ClockTime >= 6 or Lighting.ClockTime < 18 then
if Night == true then
Night = false
-- Put your code here
if Hour > 24 then
Hour = 0
game.Lighting.TimeOfDay = Hour .. ":" .. Mins .. ":" .. 0
Hey!! I 100% understand that it’s difficult to script for starters.
I’m sorry to say that a lot of your script has errors but I’m happy to help & explain!
local Lighting = game:GetService("Lighting") -- This is where you can get Lighting values.
local Door1 = workspace:WaitForChild("Door1") -- This will be "Door1" in "Workspace"
function onUpdate() -- This will be used when the "ClockTime" property is changed. (see code below, connecting this function.)
local ClockTime = Lighting.ClockTime
if (math.floor(ClockTime) < 17) then -- If its not 5PM, remove the brick (temporarily).
Door1.Parent = nil
elseif(math.floor(ClockTime) >= 17) then -- If it is & is over 5PM, show the brick.
Door1.Parent = workspace
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(onUpdate) -- This function will execute every time "ClockTime" is changed.
onUpdate() -- When the script first executes, we have to make sure everything is up to date.
There are more ways of achieving what you need, this is just a rough script & it might not work as you want it to.