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
game.Workspace.Door1(function(destroy)
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
end
end)
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â
function Time(Player)
Mins = Mins + 1
if Mins >= 60 then
Mins = 0
Hour = Hour + 1
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting.ClockTime >= 18 or Lighting.ClockTime < 6 then
if Night == false then
Night = true
--- Put your code here
end
elseif Lighting.ClockTime >= 6 or Lighting.ClockTime < 18 then
if Night == true then
Night = false
-- Put your code here
end
end
end)
if Hour > 24 then
Hour = 0
end
end
game.Lighting.TimeOfDay = Hour .. ":" .. Mins .. ":" .. 0
Time()
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
end
end
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.