#Can you make me understand this line of code (explain it to me like i'm 5)
1 messages · Page 1 of 1 (latest)
i suggest you send your code like this using 3 `s at start and end of your message and lua next to the first 3 things (or just copy this:)
local intermission = 30
local round = 300
local function countdown()
end
local function Intermission()
end
local function Round()
end
while true do
for i= intermission, 0, -1 do
print("INTERMISSION: "..i)
task.wait(1)
end
for i= round, 0, -1 do
print("ROUND: "..i)
task.wait(1)
end
end
while true do -- will always keep happening
for i= intermission, 0, -1 do -- intermission is the time of the intermission, 0 is the last number of the count, -1 means the time will go down instead of up, i is the current number (that changes everytime this loop happens)
example:
first loop:
i = 30 (because u gave the intermission amount for it)
1- will subtract 1 of 30
second loop:
i = 29 (because u subtracted 1 in the last loop)
1- will subtract 1 of 29 now
it goes like this until reaches 0, that is the number u set to be the final one
when it happens it goes to the second part of the script
print("INTERMISSION: "..i)
task.wait(1) -- this is what makes every i be subtracted each second, since u r waiting exactly one second before going to the next loop
end
-- here is the same thing as above, but for the round
for i= round, 0, -1 do
print("ROUND: "..i)
task.wait(1)
end
end
oops i send by accident lemme edit
here ya go
idk if it is confusing
if it keeps confusing u can ping me with more questions and i try to help
** You are now Level 1! **
Pro tip: you should not write timers and countdowns this way. This loop has a consistent increment aligned with an inconsistent time period; should the server or client lag, task.wait(1) will wait longer than 1 second, but the loop will still behave as if only 1 second passed
So how is good to write it?