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

Day And Night? [closed]

Asked by 9 years ago

I need a script so I can make a day and night sequence and when it gets darker the camera gets darker as well so can anyone give me the script?

0
im new to scripting so yea jadynjo1 0 — 9y
0
Since this is your first post I will give you the script BUT next time try to make your own script before posting. THIS IS NOT A REQUEST SITE! MessorAdmin 598 — 9y

Closed as Not Constructive by Shawnyg, Redbullusa, samfun123, and EzraNehemiah_TF2

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
9 years ago
Lighting = game.Lighting        -- I've set a static variable to the Lighting service.

while true do                   -- A 'while' loop is used to continuously execute this code block.
    local Time = Lighting:GetMinutesAfterMidnight() -- A local variable is used to refer to the amount of minutes after midnight.
    Lighting:SetMinutesAfterMidnight(Time + 1)  -- I've added 1 minute to the amount of minutes after midnight.
    wait(.1)                        -- A 'wait' is needed in a 'while' loop.
end

The :GetMinutesAfterMidnight method returns a number that tells you the amount of minutes after midnight.

If the 'TimeOfDay' property is set to "16:00:00", then

print(game.Lighting:GetMinutesAfterMidnight())

it will return '960' in the output (as in 960 minutes).

The :SetMinutesAfterMidnight method accepts a number and utilizes it to literally set the minutes after midnight.

game.Lighting:SetMinutesAfterMidnight(840)
print(game.Lighting.TimeOfDay)

The 'TimeOfDay' will return '14:00:00'.


A 'while' loop executes the code continuously.

A static variable is another name for a global variable. It can be accessed from anywhere (in a function, in a 'while' loop, etc).

A local variable can only be accessed in the code block it is in and in that code block only.

EXAMPLE

A = "This is from a static variable"

function Example()
    print(A)
    local A = "This is from a LOCAL variable"
    print(A)
end

print(A)

Example()

print(A)

OUTPUT:

This is from a static variable -- From line 9

This is from a static variable -- From line 4

This is from a LOCAL variable -- From line 6

This is from a static variable -- From line 13

Ad
Log in to vote
0
Answered by 9 years ago
local R=true

function Time()
for i=0,24,1 do
R=false
wait(1)
game.Lighting.TimeOfDay=i
end
R=true
end

while wait(0.1) do
if R==true then
Time()
end
end