Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Day time changing script didn't now work?

I'm try making daytime changing script, but it didn't work, this is my script.

while true do
	game.Lightning.TimeOfDay = game.Lightning.TimeOfDay + "01:00:00"
	wait(1)
end

Thx

1 answer

✓ Accepted answer

The issue is,you are trying to perform an arithmetic operation on a string value.Also,you made a common typo mistake in your code:"Lightning".

You would need to assign a number variable to store the value of the current time,then convert it into a string.

Here is an example script of what I'm talking about:

Minutes=0
Hours=0
TimeString=""
while true do
Minutes=Minutes+10
if Minutes>=60 then
Minutes=0
Hours=Hours+1
end
if Hours>24 then Hours=0 end
game.Lighting.TimeOfDay=tostring(Hours)..":"..tostring(Minutes)..":00"
wait(1)
end

I hope this helps.

12 comments

0

My original post that I deleted earlier was a mistake and confusion on my end,I apologize.

0

thx you got right answer

0

Mind upvoting my post?

0

Good job. Sure was faster then how I was going to explain it. Also, makes much more sense.... I was just gonna use a for loop.

0

Thanks! I've been programming for a long time. Also,king,timeofday is a formatted string value,not a number value. :)

0

^ I know that however, my for loop worked. I just set it equal to '1' or '2' or whatever it was.... It automatically sets the hours to 0 when they reach 24.

0

But, I never took into account the minutes because his question didn't have a delta minutes to begin with...

0

Ah.

0

Your code could be a bit neater though for reading purposes xD. Spaces would be cool.

0

Sorry,I am doing 9 things at once.Also trying to help a lot of people here,lol.

0

Nah man, it's all cool. I respect that you trying to help the community out though that's nice of you. Keep up the great work :D

0

You to bud!

This discussion is preserved as it was. New answers, comments, and votes are closed.