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

Trying To Make A Day And Night Script Isn't Working?

Asked by 3 years ago
Edited 3 years ago

Basically The Day Part Is Working And It Prints The Word But When It Reaches Night Nothing Is Printed And I Don't Know Why

Its Meant To Enable An AI Script At Night And Disable During The Day

Here Is My Script:

while true do
    wait(1)
    if game.Lighting.ClockTime > 6.3 and game.Lighting.ClockTime < 18.5 then
        print("Day")
        script.Parent.Disabled = true
    elseif game.Lighting.ClockTime < 6.3 and game.Lighting.ClockTime > 18.5 then
        print("Night")
        script.Parent.Disabled = false
    end
end

2 answers

Log in to vote
0
Answered by 3 years ago

I Found My Own Answer:

while true do
    wait(1)
    if game.Lighting:GetMinutesAfterMidnight() > 6.3 * 60 then
        print("Day")
        script.Parent.Disabled = true
    end
    if game.Lighting:GetMinutesAfterMidnight() < 6.3 * 60 then
        print("Night")
        script.Parent.Disabled = false
    end

end
Ad
Log in to vote
0
Answered by 3 years ago

You can fix your original code by using or instead of and on line 6 (since the ClockTime can't possibly be < 6.3 and > 18.5 simultaneously), or replacing line 6 with else.

Answer this question