01 | star = game.Workspace.Stars.Star |
02 | minutesAfterMidnight = 0 |
03 |
04 | if game.Lighting:GetMinutesAfterMidnight() = = 6 * 60 then -- checks for 6AM |
05 | star.Script.Disabled = false |
06 | end |
07 | if game.Lighting:GetMinutesAfterMidnight() = = 18 * 60 then -- checks for 6PM |
08 | star.Script.Disabled = true |
09 | end |
10 | end |
This is a script that checks for the time of day, and then enables/disables a script inside other parts depending on the time of day. If it means anything, it works alongside a day/night script that looks a little like this-
1 | minutesAfterMidnight = 0 |
2 | while true do |
3 | minutesAfterMidnight = minutesAfterMidnight + 1 |
4 | game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) |
5 | wait(. 1 ) |
6 | end |
I don't know if I should merge these two scripts into one or not. It's a huge mess.
It doesn't work (obviously since I'm the one who's handling it), and I think I have my problems sorted out, but I don't know how to solve them.
Problem 1. I'm not referring to the light scripts correctly.
Problem 2. I don't know how to refer to multiple items at once. (There's 10 stars, meaning 10 scripts to enable/disable)
Thanks in advance.
This is a problem. There is too many ends, and it only checks once. So in conclusion, you cannot find "Yay" in the output.
1 | local test = false |
2 | if test = = true then |
3 | primt( "Yay" ) |
4 | end |
5 | test = true |
So what you want to do is
1 | while wait(. 1 ) do |
2 | if game.Lighting:GetMinutesAfterMidnight( 6 * 60 ) then --checks if it is 6:00 am |
3 | print ( "It is 6 am!" ) |
4 | elseif game.Lighting:GetMinutesAfterMidnight( 18 * 60 ) --checks if it is 6:00 pm |
5 | print ( "It is 6 pm!" ) |
6 | end |
7 | end |
Also, I think you thing that a if statement ALWAYS has to have a ==, >, or <, so that is why you put what you put in your if atatement, but this is correct too.
1 | if game:FindFirstChild( "Workspace" ) then |
2 | print ( "Workspace exists!" ) |
3 | end |
One thing you cant do is refer to mutiple things at once, you might with :GetChildren() wich I havent tested. With that, every star has to be a diffrent name. Say you have ten parts named "Lava" in workspace and try to call a specific one. The game will be like "what do i chosse?!? do i choose the first part named Lava or the third one?!?". So name them like StarOne, StarTwo, etc.