Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does the script mean? I am really confused e.e

game.Lighting:SetMinutesAfterMidnight(5 * 60)

What does it do? Why do I have to use : What does lighting do? What is SetMinutesAfterMidnight?

1 comment

0

Did you check the roblox wiki?

2 answers

✓ Accepted answer

First of all, game.Lighting is the Lighting service. It controls all the environmental lighting, which include the time of the day, brightness, colours of light and many other things.

The SetMinutesAfterMidnight basically means the amount of minutes that have passed from midnight in the game. So you are changing the time here.

You need to use the : because SetMinutesAfterMidnight is not a property of Lighting.

3 comments

1

Correction, you do not have to use ':' in a method call. object:method(arg1, arg2, arg3, ...) is actually shorthand for object.method(object, arg1, arg2, arg3, ...). However, we generally prefer using ':' when dealing with Object Oriented Programming as it is shorter and more straightforward.

1

a.b, in Lua, means "retrieve 'b' from 'a'". Similarly, a.b(a) means "retrieve function 'b' from 'a' and then call it with 'a' as first argument".

1

Now, what we call a "method" in Object Oriented Programming is nothing more than a simple function that is attached or part of an object. That "method" or attached function, when called, can then reference and modify the attached object at will. The a:b() form implies the attached object is a, which makes it more straightforward, as you can instead think of it as "call method 'b' on obje

Alright, I agree with the answer above somewhat however, he did not cover everything. I will tell you what that script does.

#Elaboration:

###The function :SetMinutesAfterMidnight() which Roblox set for Lighting goes to 0:00:00 in the TimeOfDay property of Lighting, and adds whatever you put in the parameter.

#Conclusion:

game.Lighting:SetMinutesAfterMidnight(5*60);

###That script above will set it to 5 o' clock because it multiplies 60 by 5 and there are 60 minutes in one hour so the hours will increase 5 times.

#Reasoning:

###It does this because Roblox made their TimeOfDay property in Lighting to go to 0:00:00 when it is set to midnight and they also made it to where it goes to the next hour auto-matically when you add 60 minutes to the hour. So when you multiply 60 by 5 it makes it 5 o'clock.

Here is where you can learn more about Lighting and it's functions.

Here is where you can learn more about the :SetMinutesAfterMidnight()function of Lighting.

##I hope I helped and thank you for reading my answer. If you have any questions or concerns please comment below.

~~ KingLoneCat

This discussion is preserved as it was. New answers, comments, and votes are closed.