So I'm currently making a horror type game where at Day, its normal then at night, it gets all scary. Anyways thats not the topic right now.. I'm trying to figure out a script that can make audios and noises play in night or day separately such as only birds chirping at day and then crickets chirping at night. I also have a day to night changing script which I scripted from a tutorial but I was unable to find a tutorial on the current question I'm asking here here is the day to night script below:

local dayLength = 12

local cycleTime = dayLength*60
local minutesInADay = 24*60

local lighting = game:GetService("Lighting")

local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime

local timeRatio = minutesInADay / cycleTime

if dayLength == 0 then
	dayLength = 1
end

repeat
	local currentTime = tick()
	
	if currentTime > endTime then
		startTime = endTime
		endTime = startTime + cycleTime
	end
	
	lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
	wait(1/15)
until false

please contact me if your able to find a tutorial or recipe or somewhat, I'm very curious about this project I'm making...

3 comments

1

Check if the time is within a certain value. Example: time > 20 and time < 5 or something

0

alright

0

The site isnt a request site, its meant for questions on why something doesnt work or something