Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Day time changing script didn't now work?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago

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.

0
My original post that I deleted earlier was a mistake and confusion on my end,I apologize. Reshiram110 147 — 7y
0
thx you got right answer User#13091 0 — 7y
0
Mind upvoting my post? Reshiram110 147 — 7y
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. KingLoneCat 2642 — 7y
View all comments (8 more)
0
Thanks! I've been programming for a long time. Also,king,timeofday is a formatted string value,not a number value. :) Reshiram110 147 — 7y
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. KingLoneCat 2642 — 7y
0
But, I never took into account the minutes because his question didn't have a delta minutes to begin with... KingLoneCat 2642 — 7y
0
Ah. Reshiram110 147 — 7y
0
Your code could be a bit neater though for reading purposes xD. Spaces would be cool. KingLoneCat 2642 — 7y
0
Sorry,I am doing 9 things at once.Also trying to help a lot of people here,lol. Reshiram110 147 — 7y
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 KingLoneCat 2642 — 7y
0
You to bud! Reshiram110 147 — 7y
Ad

Answer this question