How would I do this?

Hey all, I want to make a day/night system with certain values, for example, a certain monster coming out only at night, or a shop opening only at day, like this game here made by RVVZ: The Rake REMASTERED - Roblox

Now, I am not good at scripting yet, but I think I could do it when a shop only opens up at day, what I am having a problem with is the “creature” coming out at a certain time, or just activating at a certain time. Thanks. (If you need me to elaborate more, I can)

5 Likes

I am not sure but you can use the GetPropretyChangedSignal on the clock time in game.Lighting (you don’t need a while loop for this), and when it changed just verify the time and open/close the shop or release the monsters.

example for the script (server script)

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
     if game.Lighting.ClockTime == *desired time* then
         *do action*
    elseif game.Lighting.ClockTime == *other time* then
        *do another action*
    end
end)

The ClockTime proprety is in 24 hour and decimal for example 6:15 pm will be 18.25

3 Likes

I had written property wrong in the original script make sure to correct that.

1 Like

Thanks! That helps alot! But what would I do for the daylight cycle? For example, day time last 3 minutes and night time also last for 3 minutes, without using wait(). Like a timer GUI. Thanks! :]

1 Like

To make it easier for me, I use a plugin called Realism Mod, you can change the duration of the day and the duration of the night from there.

1 Like

Now, make sure not to download those fake Realism Mods with those ‘UPDATED’ and ‘NEW’ logos. The original creator is GizmoTjaz.

1 Like

You can change the time by using this:

local lighting = game.Lighting
local thetime = 1

local function openStoreItsMorning()
      print("Open Shop")
      --any code you want here
end

while wait() do --every second
      thetime +=1 --//how many minutes to add per second (currently one)
      lighting:SetMinutesAfterMidnight(thetime) --sets the time to the variable
      if lighting.MinutesAftermidnight == 360 then --6 AM because it's 360 minutes after midnight
         openStoreItsMorning()
      elseif lighting.MinutesAftermidnight == 1439 then --check if it's 11:59 am and reset
          thetime = 0
      end
      print(lighting.TimeOfDay)
end
1 Like

I just created an open-source game for a Clock GUI that you can use if you want.

There’s a remote event in replicated storage, a script in ServerScriptService, and of course a text label in StarterGui. The day/night cycle be changed and found in the last few lines of the script. Currently, it’s set to going up 1 minute every second. So a full day would be 24 minutes long.

1 Like

Do you even have a script? It would be helpful if you show us a script if you have one.

Thanks! Almost exactly what I wanted! (not your fault though because I never disclosed it) but just like in the rake, there is a few second sunrise and moonrise, you should probably play the game to understand what I mean. Thanks!

1 Like

Also in “THE RAKE: CLASSIC EDITION” its not really day or night, its just fog, how could I just make it the fog?

1 Like

I actually do play the rake a lot! I believe I have 64 wins (or something along that line). I know exactly what you mean.

I’ll see what I can come up with to help you!

1 Like

Thanks so much! I spend way too much time in that game to the point where I have 444 survivals lol.

1 Like

Alright figured it out!

To make an effect like this, you use something called Tween Services. You can read more about that in the link below:

What we’ll want to do is create variables for the Lighting property and the TweenService. Then, we’ll create locals for the tweens.

Your script will look like this (put this in ServerScriptService):

-- Get Service
local Tween = game:GetService("TweenService") -- This basically gets the TweenService which will be used below, and we're calling it "Tween"

-- Variables
local Lighting = game:WaitForChild("Lighting") -- Get the properties for lighting

-- Locals
local NightTime = Tween:Create(Lighting, TweenInfo.new(10), {ClockTime = 0}) -- Gives the Tween for it to turn night
local NightFog = Tween:Create(Lighting, TweenInfo.new(10), {FogColor = Color3.fromRGB(0, 0, 0)})

local DayTime = Tween:Create(Lighting, TweenInfo.new(15), {ClockTime = 14}) -- Gives the Tween for it it turn day
local DayFog = Tween:Create(Lighting, TweenInfo.new(15), {FogColor = Color3.fromRGB(192, 192, 192)})

-- Tweens
while true do -- This will make the script repeat
    wait(15)
    NightTime:Play() -- 15 Seconds after a server is launched, it will do the night time tween
    NightFog:Play() -- Changes the fog color to black
    print("Nightime should have be playing") -- This you can delete if you want
    wait(11)
    DayTime:Play() -- 1 second after night time finishes playing, it will play the daytime tween.
    DayFog:Play() -- Changes the fog golor back to grey
    print("Daytime should have been played")
end

-- Please note that this is not an efficient way to order the tweens if you're creating a game like the rake, this script is only here to show you how to make that type of day/night cycle

Hope this can help.

2 Likes

To add on, here’s an open source file again:

1 Like

Once again, thank you. What would I do for it be an efficient way to order the tweens? :]

Sorry for the late response, I went to sleep.


Before using this day and night system, you’ll want to create the script that you’ll be using for a round system (there are many different ways so I suggest looking up a tutorial and finding the one you like).

Once you’ve created the round system, you should come back here and I can show you where to put that script.

2 Likes

I am sort of having trouble with this : / do you think you could recommend me a tutorial? I have already tried one but it didn’t work out at all…

There’s plenty of tutorials on creating a round system.

This one is very simple and uses just the status bar for intermissions and such (it was the only one I could find that didn’t teleport you to a lobby/map). This should work.

1 Like