My code only read one time

  1. What do you want to achieve?
    I want my code read not only one time !
  2. What is the issue?
    It read the code only one times but I can’t make several infinite loops !
  3. What solutions have you tried so far?
    I’ve tried this but I think it read the code only one time :
--variable--

local Time = game.Lighting.ClockTime
local Clouds = game.Workspace.Terrain:WaitForChild("Clouds")
local Spring = false
local Summer = false
local Autumn = false
local Winter = true
local Day = 1
local Month = 1
local Year = 2022
local LeapYear = false

--variable--

--SetTheDate--

if Time == "00:00:00" then
	Day = Day + 1
	if Month == 1 or 3 or 5 or 7 or 9 or 11 then
		if Day == 32 then
			Month = Month + 1
			Day = 1
		end
	elseif Month == 4 or 6 or 8 or 10 or 12 then
		if Day == 31 then
			Month = Month + 1
			Day = 1
		end
	elseif Month == 2 then
		if LeapYear == true then
			if Day == 30 then
				Month = Month + 1
				Day = 1
			end
		else
			if Day == 29 then
				Month = Month + 1
				Day = 1
			end
		end
	elseif Month == 13 then
		Year = Year + 1
		Month = 1
	end
end

--SetTheDate--

--Weather--

if Time == math.random(0,24) then
	if Summer then
		if math.random(0,5) < 5 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(0,50)/100
			Clouds.Color = Color3.new(1, 1, 1)
			game.Lighting.Brightness = 6
		else
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(50,75)
			Clouds.Color = Color3.new(1, 1, 1)
			game.Lighting.Brightness = 6
		end
	elseif Autumn then
		if math.random(0,2) == 1 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(50,100)/100
			Clouds.Color = Color3.new(0.713725, 0.713725, 0.713725)
			game.Lighting.Brightness = 4
			if math.random(0,10) == 1 and Clouds.Cover > 0.9 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
				Clouds.Color = Color3.new(0.458824, 0.458824, 0.458824)
				game.Lighting.Brightness = 2
			end
		elseif math.random(0,5) == 1 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(0,50)/100
			Clouds.Color = Color3.new(0.882353, 0.882353, 0.882353)
			game.Lighting.Brightness = 4
		else
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(0,25)/100
			Clouds.Color = Color3.new(1, 1, 1)
			game.Lighting.Brightness = 6
		end
	elseif Winter then
		if math.random(0,3) < 3 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(90,100)/100
			Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
			game.Lighting.Brightness = 2
			if math.random(0,3) < 3 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
			end
		else
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(70,90)/100
			Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
			game.Lighting.Brightness = 4
		end
	elseif Spring then
		if math.random(0,5) < 3 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(30,70)/100
			Clouds.Color = Color3.new(1, 1, 1)
			game.Lighting.Brightness = 6
		elseif math.random(0,5) < 5 then
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(70,90)/100
			Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
			game.Lighting.Brightness = 4
		else
			game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
			Clouds.Cover = math.random(90,100)/100
			Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
			game.Lighting.Brightness = 2
			if math.random(0,4) == 1 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
			end
		end
	end
end

--Weather--

--Season--

if Day == 21 and Month == 3 then
	Winter = false
	Spring = true
elseif Day == 21 and Month == 6 then
	Spring = false
	Summer = true
elseif Day == 21 and Month == 9 then
	Summer = false
	Autumn = true
elseif Day == 21 then
	Autumn = false
	Winter = true
end

--Season--

--CheckIfIsALeapYear--

local year = Instance.new("NumberValue")
year.Name = "Year"
year.Parent = script

year:GetPropertyChangedSignal("Value"):Connect(function()
	if year.Value % 4 == 0 then
		LeapYear = true
	else
		LeapYear = false
	end
end)

while wait() do
	year.Value = Year
end

--CheckIfIsALeapYear--

It indeed only reads one time, because there aren’t any loops.

You should try storing Time as a Value, and use GetPropertyChangedSignal to detect whenever the time changes its value.

3 Likes

Can I only GetPropertyChangedSignal if time == 0 ? :thinking:

I have do this but it does not work …

--variable--

local Clouds = game.Workspace.Terrain:WaitForChild("Clouds")
local Spring = false
local Summer = false
local Autumn = false
local Winter = true
local Day = 1
local Month = 1
local LeapYear = false


local Year = Instance.new("NumberValue")
Year.Name = "Year"
Year.Parent = script
Year.Value = 2022

local Time = Instance.new("StringValue")
Time.Name = "Time"
Time.Parent = script
Time.Value = game.Lighting.TimeOfDay

--variable--

--SetTheDate--

Time:GetPropertyChangedSignal("Value"):Connect(function()
	if Time == "00:00:00" then
		Day = Day + 1
		if Month == 1 or 3 or 5 or 7 or 9 or 11 then
			if Day == 32 then
				Month = Month + 1
				Day = 1
			end
		elseif Month == 4 or 6 or 8 or 10 or 12 then
			if Day == 31 then
				Month = Month + 1
				Day = 1
			end
		elseif Month == 2 then
			if LeapYear == true then
				if Day == 30 then
					Month = Month + 1
					Day = 1
				end
			else
				if Day == 29 then
					Month = Month + 1
					Day = 1
				end
			end
		elseif Month == 13 then
			Year = Year + 1
			Month = 1
		end
	end
end)

--SetTheDate--

--Weather--

Time:GetPropertyChangedSignal("Value"):Connect(function()
	if Time == "12:00:00" then
		if Summer then
			if math.random(0,5) < 5 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(0,50)/100
				Clouds.Color = Color3.new(1, 1, 1)
				game.Lighting.Brightness = 6
			else
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(50,75)
				Clouds.Color = Color3.new(1, 1, 1)
				game.Lighting.Brightness = 6
			end
		elseif Autumn then
			if math.random(0,2) == 1 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(50,100)/100
				Clouds.Color = Color3.new(0.713725, 0.713725, 0.713725)
				game.Lighting.Brightness = 4
				if math.random(0,10) == 1 and Clouds.Cover > 0.9 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
					Clouds.Color = Color3.new(0.458824, 0.458824, 0.458824)
					game.Lighting.Brightness = 2
				end
			elseif math.random(0,5) == 1 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(0,50)/100
				Clouds.Color = Color3.new(0.882353, 0.882353, 0.882353)
				game.Lighting.Brightness = 4
			else
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(0,25)/100
				Clouds.Color = Color3.new(1, 1, 1)
				game.Lighting.Brightness = 6
			end
		elseif Winter then
			if math.random(0,3) < 3 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(90,100)/100
				Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
				game.Lighting.Brightness = 2
				if math.random(0,3) < 3 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
				end
			else
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(70,90)/100
				Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
				game.Lighting.Brightness = 4
			end
		elseif Spring then
			if math.random(0,5) < 3 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(30,70)/100
				Clouds.Color = Color3.new(1, 1, 1)
				game.Lighting.Brightness = 6
			elseif math.random(0,5) < 5 then
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(70,90)/100
				Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
				game.Lighting.Brightness = 4
			else
				game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
				Clouds.Cover = math.random(90,100)/100
				Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
				game.Lighting.Brightness = 2
				if math.random(0,4) == 1 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
				end
			end
		end
	end
end)

--Weather--

--Season--


if Day == 21 and Month == 3 then
	Winter = false
	Spring = true
elseif Day == 21 and Month == 6 then
	Spring = false
	Summer = true
elseif Day == 21 and Month == 9 then
	Summer = false
	Autumn = true
elseif Day == 21 then
	Autumn = false
	Winter = true
end

--Season--

--CheckIfIsALeapYear--

Year:GetPropertyChangedSignal("Value"):Connect(function()
	if Year.Value % 4 == 0 then
		LeapYear = true
	else
		LeapYear = false
	end
end)

--CheckIfIsALeapYear--

while wait() do
	Time.Value = game.Lighting.TimeOfDay
end

Is it a localscript? Where is it located?

1 Like

Its Time.Value == 00:00:00

char limit

1 Like

It is a script in ServerScriptService ! :grinning:

Thank you I changed but it still does not work ! :disappointed_relieved::wink:

Localscripts cannot access serverscriptservice, and neither they can CHANGE the values replicated to the server, note it.

1 Like

Why are you talking about local script I mentioned a “script in ServerScriptService” ? :face_with_raised_eyebrow:

Just make the script in a “while true do” loop
do it like this:

while true do
--put your script code in here
end
1 Like

I found a solution on my own but thank you very much ! :yum:

Here my new code, I used spawn(function() :

--variable--

local Clouds = game.Workspace.Terrain:WaitForChild("Clouds")
local Spring = false
local Summer = false
local Autumn = false
local Winter = true
local Day = 1
local Month = 1
local Year = 2022
local LeapYear = false
local Time

--variable--

--SetTime--

spawn(function()
	while wait() do
		Time = game.Lighting.TimeOfDay
	end
end)

--SetTime--

--SetTheDate--

spawn(function()
	while wait() do
		if Time == "00:00:00" then
			Day = Day + 1
			if Month == 1 or 3 or 5 or 7 or 9 or 11 then
				if Day == 32 then
					Month = Month + 1
					Day = 1
				end
			elseif Month == 4 or 6 or 8 or 10 or 12 then
				if Day == 31 then
					Month = Month + 1
					Day = 1
				end
			elseif Month == 2 then
				if LeapYear == true then
					if Day == 30 then
						Month = Month + 1
						Day = 1
					end
				else
					if Day == 29 then
						Month = Month + 1
						Day = 1
					end
				end
			elseif Month == 13 then
				Year = Year + 1
				Month = 1
			end
		end
	end
end)

--SetTheDate--

--CheckIfIsALeapYear--

spawn(function()
	while wait() do
		if Year.Value % 4 == 0 then
			LeapYear = true
		else
			LeapYear = false
		end
	end
end)

--CheckIfIsALeapYear--

--Season--

spawn(function()
	while wait() do
		if Day == 21 and Month == 3 then
			Winter = false
			Spring = true
		elseif Day == 21 and Month == 6 then
			Spring = false
			Summer = true
		elseif Day == 21 and Month == 9 then
			Summer = false
			Autumn = true
		elseif Day == 21 then
			Autumn = false
			Winter = true
		end
	end
end)


--Season--

--Weather--

spawn(function()
	while wait() do
		if Time == "12:00:00" then
			if Summer then
				if math.random(0,5) < 5 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(0,50)/100
					Clouds.Color = Color3.new(1, 1, 1)
					game.Lighting.Brightness = 6
				else
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(50,75)
					Clouds.Color = Color3.new(1, 1, 1)
					game.Lighting.Brightness = 6
				end
			elseif Autumn then
				if math.random(0,2) == 1 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(50,100)/100
					Clouds.Color = Color3.new(0.713725, 0.713725, 0.713725)
					game.Lighting.Brightness = 4
					if math.random(0,10) == 1 and Clouds.Cover > 0.9 then
						game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
						Clouds.Color = Color3.new(0.458824, 0.458824, 0.458824)
						game.Lighting.Brightness = 2
					end
				elseif math.random(0,5) == 1 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(0,50)/100
					Clouds.Color = Color3.new(0.882353, 0.882353, 0.882353)
					game.Lighting.Brightness = 4
				else
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(0,25)/100
					Clouds.Color = Color3.new(1, 1, 1)
					game.Lighting.Brightness = 6
				end
			elseif Winter then
				if math.random(0,3) < 3 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(90,100)/100
					Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
					game.Lighting.Brightness = 2
					if math.random(0,3) < 3 then
						game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
						print("rain")
					end
				else
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(70,90)/100
					Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
					game.Lighting.Brightness = 4
				end
			elseif Spring then
				if math.random(0,5) < 3 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(30,70)/100
					Clouds.Color = Color3.new(1, 1, 1)
					game.Lighting.Brightness = 6
				elseif math.random(0,5) < 5 then
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(70,90)/100
					Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
					game.Lighting.Brightness = 4
				else
					game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
					Clouds.Cover = math.random(90,100)/100
					Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
					game.Lighting.Brightness = 2
					if math.random(0,4) == 1 then
						game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
					end
				end
			end
		end
	end
end)

--Weather--