-
**What do you want to achieve?
I am trying to make a door that opens at 5:30 AM (in-game time) and closes at 8:30 PM. -
What is the issue? Include screenshots / videos if possible!
I have tried the code below, but it doesn’t work. when the ClockTime reaches 5.5, the ‘CanCollide’ Property of the door remains true. -
What solutions have you tried so far?
I tried looking here and tried multiple scripts, but nothing has worked.
The script is meant to open the door (union part named ‘Door’)
(set the ‘CanCollide’ property to false and the ‘Transparency’ property to 1)
whenever the time reaches 5:30 AM, and then close the door
(set the ‘CanCollide’ property to true and the ‘Transparency’ property to 0)
when it reaches 8:30 PM
The comments in the script are just me explaining my thought process when I wrote the script
local Door = script.Parent
local ClockTime = game.Lighting.ClockTime
while true do
if ClockTime >= 17.5 or ClockTime <= 5.5 then
-- checking if the time is between 8:30 PM and 5:30 AM
-- (when the door should be closed)
Door.CanCollide = true
Door.Transparency = 0
else
--if it is not between 8:30 PM and 5:30 AM, open the door
Door.CanCollide = false
Door.Transparency = 1
end
wait(0.1)
end
I am very new to scripting
Any help will be appreciated