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

How can I make a script activate when it is a certain time of day?

Asked by 6 years ago

So lets say it was time 00:0000 (24), how could I make a script activate? Eg; Nightlights

1 answer

Log in to vote
0
Answered by 6 years ago

Hi, IPhoneDrew. The solution to your question, "How can I make a script activate when it is a certain time of day?", can be found on the Changing Time of Day – Making a Day/Night Cycle

-- This code is completely from the wiki linked above

lightPart = game.Workspace.LightPart
minutesAfterMidnight = 0

while true do
    minutesAfterMidnight = minutesAfterMidnight + 10
    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
    wait(0.1)

    if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then       -- checks for 6AM
        lightPart.Material = Enum.Material.Plastic
        lightPart.PointLight.Enabled = false
    end
    if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then      -- checks for 6PM
        lightPart.Material = Enum.Material.Neon
        lightPart.PointLight.Enabled = true
    end
end
0
Thank you! IPhoneDrew 9 — 6y
Ad

Answer this question