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

game.Lighting.LightingChanged:connect(function(TimeOfDay)
    if TimeOfDay then
        game.Workspace.Security.Rear.Open.R.Enabled = false
        game.Workspace.Security.Rear.Open.L.Enabled = false
        game.Workspace.Security.Front.Open.R.Enabled = false
        game.Workspace.Security.Front.Open.L.Enabled = false
    else
        game.Workspace.Security.Rear.Open.R.Enabled = true
        game.Workspace.Security.Rear.Open.L.Enabled = true
        game.Workspace.Security.Front.Open.R.Enabled = true
        game.Workspace.Security.Front.Open.L.Enabled = true
    end
end)


if game.Lighting.TimeOfDay == "21:00:00" then
    game.Workspace.Security.Rear.Open.R.Enabled = false
    game.Workspace.Security.Rear.Open.L.Enabled = false
    game.Workspace.Security.Front.Open.R.Enabled = false
    game.Workspace.Security.Front.Open.L.Enabled = false

elseif game.Lighting.TimeOfDay == "06:00:00" then
    game.Workspace.Security.Rear.Open.R.Enabled = true
    game.Workspace.Security.Rear.Open.L.Enabled = true
    game.Workspace.Security.Front.Open.R.Enabled = true
    game.Workspace.Security.Front.Open.L.Enabled = true
end
game.Lighting.TimeOfDay.Changed:connect(function()
    if game.Lighting.TimeOfDay == "21:00:00" then -- Night
        game.Workspace.Security.Rear.Open.R.Disabled = true
        game.Workspace.Security.Rear.Open.L.Disabled = true
        game.Workspace.Security.Front.Open.R.Disabled = true
        game.Workspace.Security.Front.Open.L.Disabled = true

    elseif game.Lighting.TimeOfDay == "6:00:00" then --Day
        game.Workspace.Security.Rear.Open.R.Disabled = false
        game.Workspace.Security.Rear.Open.L.Disabled = false
        game.Workspace.Security.Front.Open.R.Disabled = false
        game.Workspace.Security.Front.Open.L.Disabled = false
    end
end)

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:

while wait() do
if game.Lighting.TimeOfDay == "21:00:00" then
    game.Workspace.Security.Rear.Open.R.Enabled = false
    game.Workspace.Security.Rear.Open.L.Enabled = false
    game.Workspace.Security.Front.Open.R.Enabled = false
    game.Workspace.Security.Front.Open.L.Enabled = false

elseif game.Lighting.TimeOfDay == "06:00:00" then
    game.Workspace.Security.Rear.Open.R.Enabled = true
    game.Workspace.Security.Rear.Open.L.Enabled = true
    game.Workspace.Security.Front.Open.R.Enabled = true
    game.Workspace.Security.Front.Open.L.Enabled = true
end
end
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