star = game.Workspace.Stars.Star minutesAfterMidnight = 0 if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then -- checks for 6AM star.Script.Disabled = false end if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then -- checks for 6PM star.Script.Disabled = true end 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-
minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 1 game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(.1) 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.
local test = false if test == true then primt("Yay") end test = true
So what you want to do is
while wait(.1) do if game.Lighting:GetMinutesAfterMidnight(6 * 60) then --checks if it is 6:00 am print("It is 6 am!") elseif game.Lighting:GetMinutesAfterMidnight(18 * 60) --checks if it is 6:00 pm print("It is 6 pm!") end 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.
if game:FindFirstChild("Workspace") then print("Workspace exists!") 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.