Answers for "set time roblox studio script"

1

Day/Night script in roblox studio

-- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
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
Posted by: Guest on October-16-2020
0

how to make a day/night script roblox

while wait(0.3) do
	game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+1)
end
Posted by: Guest on April-17-2020

Browse Popular Code Answers by Language