Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Time of day = Script Disables? [ANSWERED]

Asked by 9 years ago

So. I have a script in which when the time reaches 21:00:00, or 9pm, the scripts to open a gate stop working and then when the time reached 6:00:00 it re-activates.... BUT, it doesn't work, could someone help?

So. I have 3 different codes which all don't work, making even 1 of them work would be a miracle

01game.Lighting.LightingChanged:connect(function(TimeOfDay)
02    if TimeOfDay then
03        game.Workspace.Security.Rear.Open.R.Enabled = false
04        game.Workspace.Security.Rear.Open.L.Enabled = false
05        game.Workspace.Security.Front.Open.R.Enabled = false
06        game.Workspace.Security.Front.Open.L.Enabled = false
07    else
08        game.Workspace.Security.Rear.Open.R.Enabled = true
09        game.Workspace.Security.Rear.Open.L.Enabled = true
10        game.Workspace.Security.Front.Open.R.Enabled = true
11        game.Workspace.Security.Front.Open.L.Enabled = true
12    end
13end)
01if game.Lighting.TimeOfDay == "21:00:00" then
02    game.Workspace.Security.Rear.Open.R.Enabled = false
03    game.Workspace.Security.Rear.Open.L.Enabled = false
04    game.Workspace.Security.Front.Open.R.Enabled = false
05    game.Workspace.Security.Front.Open.L.Enabled = false
06 
07elseif game.Lighting.TimeOfDay == "06:00:00" then
08    game.Workspace.Security.Rear.Open.R.Enabled = true
09    game.Workspace.Security.Rear.Open.L.Enabled = true
10    game.Workspace.Security.Front.Open.R.Enabled = true
11    game.Workspace.Security.Front.Open.L.Enabled = true
12end
01game.Lighting.TimeOfDay.Changed:connect(function()
02    if game.Lighting.TimeOfDay == "21:00:00" then -- Night
03        game.Workspace.Security.Rear.Open.R.Disabled = true
04        game.Workspace.Security.Rear.Open.L.Disabled = true
05        game.Workspace.Security.Front.Open.R.Disabled = true
06        game.Workspace.Security.Front.Open.L.Disabled = true
07 
08    elseif game.Lighting.TimeOfDay == "6:00:00" then --Day
09        game.Workspace.Security.Rear.Open.R.Disabled = false
10        game.Workspace.Security.Rear.Open.L.Disabled = false
11        game.Workspace.Security.Front.Open.R.Disabled = false
12        game.Workspace.Security.Front.Open.L.Disabled = false
13    end
14end)
0
its game.Lighting.Changed and i'ts that on 3rd scripr too TheDeadlyPanther 2460 — 9y

2 answers

Log in to vote
1
Answered by
Wutras 294 Moderation Voter
9 years ago

Nvm, I just realized that you could just make it a loop to check for it all the time. Here you go:

01while wait() do
02if game.Lighting.TimeOfDay == "21:00:00" then
03    game.Workspace.Security.Rear.Open.R.Enabled = false
04    game.Workspace.Security.Rear.Open.L.Enabled = false
05    game.Workspace.Security.Front.Open.R.Enabled = false
06    game.Workspace.Security.Front.Open.L.Enabled = false
07 
08elseif game.Lighting.TimeOfDay == "06:00:00" then
09    game.Workspace.Security.Rear.Open.R.Enabled = true
10    game.Workspace.Security.Rear.Open.L.Enabled = true
11    game.Workspace.Security.Front.Open.R.Enabled = true
12    game.Workspace.Security.Front.Open.L.Enabled = true
13end
14end
0
Yes, do you want a copy of what the script says? TheHospitalDev 1134 — 9y
0
Sure Wutras 294 — 9y
2
Edited my answer, I'd really much appreciate an upvote, etc. Wutras 294 — 9y
Ad
Log in to vote
-3
Answered by 9 years ago

I bet you put this script in Lighting, put it somwhere like Workspace or ServerScriptService

Answer this question