@@الخلبوصةwhy is your handle from right to left, is it because your language reads from right to left, just some random comment from me to distract my self from the stress of scripting
As a returning scripter, I find that there are barely any TH-camrs making tutorials on scripting, and the fact that this one is up-to-date with the current state of roblox studio, is just amazing. I definitely find episodes 10 and higher good for re-learning, the previous ones are easy to learn and never forget :D
I have watched from #1 to #12 in one day, filling my journal with notes and having so much fun! I can't wait until I can learn the more advanced and involved scripting. I am loving your series so far and plan on watching your other roblox studio playlists. Thank you so much for making such helpful content!!!! :D
bruh ppl are so lazy, there was 70k+ on ur 1st beginner vid now its legit less than a 10th of ur previous views like whats the point of watching when ur not even gonna finish the playlist bru or maybe they just watched ur first guide and never seen the playlist
Honestly, This has helped me out alot, Before, I tried 4 TIMES to get into scripting but could not find the right tutorials and they were to difficult for beginners as they would jump straight to advanced stuff. So, I thought to give this a try and now im HOOKED to this, I can confidently say, I have learnt alot from this series up till now and I hope to finish the advanced series as well.
sometimes BrawlDev explains a concept, and i wonder what the heck i'm going to use it for, for example, breaks, if you want your script to run 200 times, then set it to 200 why use breaks, but then i realised that if you pair this with variables it can be crucial for making levels and xp
-- Loop through numbers from 1 to 100000 for i = 1, 100000 do -- Check if the current value of i is equal to 10 if i == 10 then print("i is equal to 10, so we'll skip this iteration") -- Instead of using continue, we'll use a workaround to skip the current iteration -- by simply not executing the following print statement else -- Print a message for each iteration that is not skipped or stopped print("Iteration number " .. i .. ": I'm still going strong!") end -- Check if the current value of i is equal to 200 if i == 200 then print("i has reached 200, breaking out of the loop") break -- Exit the loop entirely when i equals 200 end end --[[ print("Exited the for loop") -- A second loop that uses a while loop to demonstrate longer iteration control local counter = 1 -- Initialize a counter variable -- Continue looping as long as the counter is less than or equal to 10000000 while counter
I finished this long ago but its always a good think to be back to basics! it gets overwhelming to remember simple stuff when things start to get complex.
Bro i was legit stuck on this specific problem with the loop and not running the other line and an hour later i solved it myself just to realize i couldve continued the plalist and watch your vid😢😢
for i = 1, 42000 do -- third value of i statement is default as 1 if i == 10 then print('index is currently at 10, skip this iteration') continue end
print("another DEAD to gang violence")
if i == 500 then break end end for i = 1, 15, 1 do -- prints after the break statement above print("you want this to print") end local count = 1 while count
Did you know that at least 9 million people have the same birthday as you? Summary of the video: Differences between break & continue: continue: Used in any loop to skip the current iteration of the loop (think an iteration as the total execution count of the loop, so the first time the loop runs, its iteration count will be 1, and then 2, and then 3, ect. So, if we are in the iteration 4, and we skip the 5th iteration, it would go from 4 to 6) Example: for i = 1, 10 do if i == 5 then continue end print(i) end -- This would print: 1, 2, 3, 4, 6, 7, 8, 9, 10 (5 is skipped) break: used to stop TOTALLY a loop, so it doesnt execute anymore and continue to the code below it.
6:42 brawl when you forgot to add the break i run the script and Roblox studio stoped working for on minute and then when I checked the output it said (this while statement is printed x4994 times)
You can use the Spawn() function, it basically isolates the loop so it runs with the rest of the script without waiting for the loop to finish. This can come in handy in some situations
for i = 1, 5 do print("Hello..") if i == 3 then print("skip hello and print Hi! 5 times. then continue with the last 2 Hello's") for i = 1, 5 do print("hi!") end continue end end
--[[testing bracket]] for goo = 1,100,1 do print("counting currently") if goo ==10 then print("goo is now at 10") task.wait(5) --unanchors ball 1 workspace.greenba.Anchored=false task.wait(1) end if goo ==30 then print("goo is now at 30") task.wait(5) --unanchors ball 2 workspace.yellowba.Anchored=false task.wait(1) end if goo >=50 then -- im gonna make the ball fall slower on 50 print("its over 50. time to stop.") task.wait(5) --unanchors ball 3 workspace.Gravity = 20 workspace.redba.Anchored=false print("wait 5 seconds for normal gravity") task.wait(5) workspace.Gravity= 196 print("one seconds passed. now breaked") break end end
i crashed while trying to do while continue loops myself without finishing this vid :3 i found out that i forgot to make the while loops add loops so it ran inf
I went back to the math tutorial and added some comments because I had a bit of trouble understanding. -- For addition, it takes these 2 numbers as an example and moves on to the result variable. as you can see, its adding those 2 numbers together (example numbers) -- Then it returns the result and ends the function. It creates a new variable and uses the addition function with 2 diffrent numbers. Thanks to the result variable, your able to add it because its taking those 2 example numbers and adding them. -- After that its just printing the print result. local function addition(number1, number2) local result = number1 + number2 return result end local printresult = addition(8,2) print(printresult) local function subtraction(number1, number2) local result = number1 - number2 return result end local printresult = subtraction(2, 2) print(printresult) local function division(number1, number2) local result = number1 / number2 return result end local printresult = division(8,2) print(printresult) local function multiplication(number1, number2) local result = number1 * number2 return result end local printresult = multiplication(2, 2) print(printresult)
I don’t recommend nested loops for you beginners because nested loops can cause a confusion for your coding so try not to nest your coding and be one of the never nesters but do use what brawl dev shows
I tried to make a nested loop, and I don't recommend doing one even if my code actually worked. It takes too long, and you need to be very careful in how you are organizing the different loops. If I hadn't known if statements, it would have been simply impossible, and I still had to use break and continue with the if statements, since something in the loops went wrong and I had to use other alternatives to end one and start the other.
for conter = 2, 100, 2 do print("Hello") print("Hi") if conter == 9 then print("hello print me") end if conter == 10 then print("meow") end if conter == 13 then print("Helllloooooo") end if conter == 14 then print("don't skip me") end if conter == 16 then print("ok stop that") break end end local zconter = 1 while zconter
Bro you are my favorite youtuber at this point you just look at my brain and answer my questions bro i finally found a tutorial that explains good and understandbly keep going your the best!
simple silly countdown for counter = 10, 1, -1 do if counter == 5 then print(" 5 seconds left????") task.wait(1) continue end print(counter) task.wait(1) end
- loops for s = 1, 1000000 do - if s is 9, print if s == 9 then print(“this is also a string”) continue end - if s is 500, stop the loop if s == 500 then break end - if none of those are met, print. print(“this is a string”) end
Thanks bro for this amazing vidoes and tutorial and that my script and hope anyone use it!! --this is for loop goes through 100000 iterations until certain conditions are meet for i = 1, 10000 do if i == 10 then print(" i is equal to 10 so, skip this!!") continue end
if i == 200 then break end
print("this statement is printed") end local counter = 1 while counter
for k = 1,19 do if k == 50 then -- check if current value of k is 50 print("k is equal to 19, skipping the iteration") continue end print("this statement will be printed ") end local counter = 1 while counter
For a lot of the scripts we have done i have been adding comments as notes for myCounter2 = 1, 5, 1 do print("statement B") end end -- For loops need 3 numbers 1. Start 2. End 3. Increment --Nested loops lets you place loops inside loops for i = 1, 100000 do print("statement printed")
if i == 200 then break end end local counter = 1 while counter
-- This for loop goes through 100000 iterations until certain conditions are met for i = 1, 100000 do if i == 10 then print("i is equal to 10, so skip this iteration") continue end
if i == 200 then break end
print("this statement is printed") end --[[local counter = 1 while counter
-- ill attempt to make this change the colour of the baseplate til certain conditions are met local baseplate = game.Workspace.Baseplate for myCounter = 1, 100000 do baseplate.BrickColor = BrickColor.Random() wait(0.1)
if baseplate.BrickColor == BrickColor.new("Toothpaste") then print("this") continue end
if baseplate.BrickColor == BrickColor.new("Really red") then break end end --[[ local counter = 1 while counter
I love these tutorials they explain the concepts very well but I’m always stuck asking “why would I need to know/do this” because what game needs something printed 100 times or what game needs a function to add numbers together. I love these tutorials but I wish there were more actual use application examples
-- this for loop prints 'this is for my episode #12 learning objective' once when I -- is equal to 10 and 'keep printing me 20 times' for i = 1, 1000 do if i == 10 then print("This is for my episode #12 learning objective") continue end
for learning objective i made that : for i = 1,5 do local part66 = game.Workspace.part66 wait(0.1) part66.BrickColor = BrickColor.new("Really red") wait(0.1) part66.BrickColor = BrickColor.new("Gold") if i == 2 then part66.Transparency = 1
end if i == 2 then break
end
end -------------------------------------------------------------- for u = 1,10 do if u == 6 then print("skip this iteration") continue -- it will not write ("hi guys") for 6 times because I wrote continue end
if u == 7 then -- if u reaches 7 times it will stop due to using break break end
print("hi guys") --it will print hi guys for 5 times
end --------------------------- for o = 1, 100 do if o == 50 then print("Nice Day") continue end
I've always had a hard time learning loops- but this episode taught me so much, thanks! This is my code (don't be discouraged and don't give up! I nearly gave up myself, but always keep in mind of your ultimate goals!) local function yourLevel () for i = 1,10,1 do local LevelPrinted = math.random(1,500)
if LevelPrinted 100 and LevelPrinted 200 and LevelPrinted 300 and LevelPrinted 400 and LevelPrinted
for i = 1, 20 do -- Check if the number is even if i % 2 == 0 then continue -- Skip to the next iteration if the number is even end -- Print the odd number print("Number:", i) -- Check if the number is greater than 15 if i > 15 then print("Breaking the loop at:", i) break -- Stop the loop if the number is greater than 15 end end
local block = game.Workspace.Part local function RGBPART() print("RGBPART function started") for i = 1, 100, 1 do task.wait(0.25) block.BrickColor = BrickColor.new(255, 0, 0) task.wait(0.25) block.BrickColor = BrickColor.new(0, 255, 0) task.wait(0.25) block.BrickColor = BrickColor.new(0, 0, 255) if i == 10 then print("Color changed 30 times!") end end end RGBPART()
Short and simple this time: for number = 1, 50 do if number % 2 == 0 then print(number) continue end if number >= 20 then print("Love even numbers") break end end
i made this cool loading screen in the output u guys can try it if u want:) for myloop = 1, 10 do if myloop == 5 then print("Loading assets") task.wait(1) continue end
if myloop == 10 then print("Starting") wait(5) print("Lets go") break end
I don't think the purposes of break and continue were really articulated in this tutorial, but I guess I'll understand when the scripts get more sophisticated. My HW: --The following code of a for loop prints 100 times, skipping the 50th iteration and stopping at the 75th for i = 1, 100 do if i == 50 then print("Skip the 50th iteration") end
if i == 75 then print("Stop at the 75th iteration") break end
if math.random(1, 10) == 10 then -- skips randomly (chances are high, I don't want it to just skip once) print("skip this iteration") continue end
if math.random(1, 200) == 1 then -- breaks randomly print("the loop has stopped on loop", i) break end print("there has been", i, "printed loops") -- shows the loop you are on. end
Here's what I put. -- Example 1 for i = 1, 100000 do if i == 10 then print("i is equal to 10, so skip this iteration") -- Tells me when it reaches 10. continue
end
if i == 50 then break -- If it reaches 50, stop. end
print("end of for loop") end -- Example 2 for i = 1, 100000 do -- This for loop goes through 100000 iterations until certain conditions are met. if i == 10 then print("i is equal to 10, so skip this iteration") continue end
if i == 20 then break end
print("this statement is printed") end -- Example 3 local counter = 1 while counter
for i = 1, 100 do if i == 10 then print("skip this iteration") continue -- skip the rest of the code and go back up end print("Statement") end local counter = 0 while counter
--Conditions met to break a loop in code for i = 1, 100000 do if i == 10 then print("i is equal to 10, so thy code shall skip this iteration") continue end
if i == 200 then break end end local counter = 1 while counter
-- Counts up from 1 to 100 for Counter = 1, 100, 1 do -- Mentions in an external print statement that the counter is at 25 if Counter == 25 then print("Counter is at 25") continue end -- Mentions that the counter is at 50 and breaks loop if Counter == 50 then print("Counter is at 50") break end -- Prints the amount the counter is at (From 1 to 100 excepting 25 and 50 (stopped at 50 (I love parentheses))) print("Counter is at "..(Counter)) end
for i = 1, 100000 do print("this statement is printed") if i == 10 then print("this statement is also printed") continue end if i == 200 then break end end
--This for loop goes through 100000 iterations until certain conditions are met for i = 1, 100000 do if i == 10 then print("i is equal to 10 so skip this iteration") continue end
if i == 200 then break end
print("This statement is printed")
end -- print("hello") --[[ add aejh dfj zxh gff ]] --[[local counter = 1 while counter
for congcong = 1, 500 do print("congcong") if congcong == 30 then print("congcong have 30") continue end if congcong == 100 then print("congcong is too many") break end end local abc = 1 while abc
--This loop goes through 10000 iteratiions unyil certain conditions are met. for i = 1, 10000 do if i == 10 then print("i is equal to 10, so skip this iteration") continue end
if i == 500 then break end
print("This statement is printed")
if i == 200 then break end end --[[local counter = 1 while counter
heres what i did for a while loop example: --while loop example-- local dog = 1 while dog = 100 then print("No, it's a wolf!") --when dogVariable reaches break -->=100 it will print this once end --and break the code to end the -- whole while loop. end --output: --This is a dog. (x99) --No, it's a wolf! --[[ both 'if' statements run, but since the second reads back as false only the first 'if' stment will actually fire. bc it skips the second one, bc of it stating false, but when dogVariable reaches 100, it is true and runs: and breaks the code block after the 2nd 'if' statement code block is over. ]]
for o = 1, 1000 do if o == 10 then print("O is now equal to ten") end if o == 400 then break end
if g == 100 then g = o print('The value of G is now equal to O = 100') end print('O is now equal to' ..o.."")
g = g + 1 end
for i = 1, 100000 do if i ==10 then print("i is equal to" .. i .. ", so skip this iteration") end if i == 200 then break end print("This statement is printed. I =" .. i .."") end end testcounter() --ik that this is long as hell but i just want to make something that looks fancy lol
im basically writing a random script here its is: -- using for loops for i = 1, 1000000000000000000, 1 do if i == 666 then print("Skip this number, this number is horrid") continue end
if i == 1000 then break end
print("iam being printed out") end -- the same but using while loops local i = 1 while i < 1000000000000000000 do if i == 666 then print("Skip this number, this number is horrid") continue end
if i == 1000 then break end print("iam being printed out using while loops") end
local a = 1 while a < 20 do -- This will repeat until a is greater than 20 print("I really like cheese") if a == 10 then -- This will stop the loop and print something different than skip past number 11 print("I also like to eat cheese") a = a + 2 continue end if a == 11 then -- if this happens then there was an error in the code and it will stop the loop print("This was not supposed to happen....") break end a = a + 1 end
I combined the previous few episodes to come up with this. Also learnt a new concept with the help of gbt Man AI is making our life easier and is letting us learn anything way faster and efficient. Imagine how hard it would be back in the 2016 days to learn how to script local firstbreak = false for i = 1, 1000 do if not firstbreak and i == 100 then print("It is 100") firstbreak = true end
for hello = 1, 50 do if hello == 14 then print("this statement is cool") continue end end for bye = 1, 403 do if bye == 12 then print("this statement is good") break end end
Here is what i did! for loop = 1, 10 do if loop == 10 then print("loop is equal to 10, so skip this iteration!") continue end print("i like eating burgers") end local chicken = 1 while chicken
Here is a timer script using a while loop. local counter = 1 while counter = 1 do script.Parent.Text = counter + 1 task.wait(1) counter = counter + 1 if counter == 10 then break end end The differences here is in the first once to not have to use a break loop I said while counter is =1 which means if I never added the break loop, it would go on forever.
here is da script if you wanna try it for urself you can: for i = 1, 100000 do if i == 10 then print("i is equal to 10, so skip this iteration!") continue end
if i == 200 then break end end local counter = 1 while counter
i truly do not understand the concept of continue statements. i get they skip an iteration but why would i want to do that? if my break hits 200 it ends but if i have it so when it hits 20 it continues it just skips 20 in the count. like whats the point i truly dont get it
For some reason I was quite confused but in the end I understood, pretty cool stuff! --[[ Yo this is cool, so this is a comment with multiple lines! ]] --Continue for i = 1, 69 do if i == 10 then print("this is 10") continue end print("cool") end --Break for i = 1, 200 do print("ay, 69 times?") if i == 69 then break end end
uhh i didnt really know what to do so i just copied ur code but alternated it for i = 1, 100000 do if i == 15 then print("i is equal to 15 so skip") continue end if i == 1000 then break end
Here's what I did for the learning objective! for airplaneCount = 1, 419 do if airplaneCount == 100 then print("100 airplane jackpot!!!") continue end print(airplaneCount)
end theCoolestVariable = 1 while theCoolestVariable
for a = 1, 100 do --[[This will check to see if a = 10, if it does than it will say its equal to 10, it will also check if its equal to 20 if it is than it will say its equal to 20. If not it will continue print ]] if a == 10 then print("a is equal to 10!") elseif a == 20 then print("a is equal to 20!") continue end -- This will break the print("a") loop if a == 50 then break end
-- This for loop goes through 100000 interations until certain condeitionps are met for i = 1, 100000 do if i == 1000 then print("IT HAS PASSED ONE THOUSAND") end if i == 1100 then break end end thx man i love ya better then all the other videos
"As long as you understand it I think it'll make sense."
-BrawlDev
Yes I liked my own comment
Eu gosto é assim Amostradinho💀
@@henriquebigolin2006💀🙏
@@الخلبوصةbro commented more on this channel, than I ever commented on youtube💀
@@الخلبوصةwhy is your handle from right to left, is it because your language reads from right to left, just some random comment from me to distract my self from the stress of scripting
As a returning scripter, I find that there are barely any TH-camrs making tutorials on scripting, and the fact that this one is up-to-date with the current state of roblox studio, is just amazing.
I definitely find episodes 10 and higher good for re-learning, the previous ones are easy to learn and never forget :D
I have watched from #1 to #12 in one day, filling my journal with notes and having so much fun! I can't wait until I can learn the more advanced and involved scripting. I am loving your series so far and plan on watching your other roblox studio playlists. Thank you so much for making such helpful content!!!! :D
instead of writing "counter = counter + 1" , you can write it shorter by saying "counter += 1" which basically means the same thing :) .
Ty brooda
good jo
thanks needed that
Ily
Thanks dude
bruh ppl are so lazy, there was 70k+ on ur 1st beginner vid now its legit less than a 10th of ur previous views like whats the point of watching when ur not even gonna finish the playlist bru or maybe they just watched ur first guide and never seen the playlist
Fr
Less competition I guess
people don't need to share the same interests as us they're not lazy.
Honestly, This has helped me out alot, Before, I tried 4 TIMES to get into scripting but could not find the right tutorials and they were to difficult for beginners as they would jump straight to advanced stuff. So, I thought to give this a try and now im HOOKED to this, I can confidently say, I have learnt alot from this series up till now and I hope to finish the advanced series as well.
well well well do you still script
@@ItsukiXi Took a break after exams, so its been quite a while, i will def continue soon
@@Zh1xy how is it now
@@Zh1xy any games yet
sometimes BrawlDev explains a concept, and i wonder what the heck i'm going to use it for, for example, breaks, if you want your script to run 200 times, then set it to 200 why use breaks, but then i realised that if you pair this with variables it can be crucial for making levels and xp
-- Loop through numbers from 1 to 100000
for i = 1, 100000 do
-- Check if the current value of i is equal to 10
if i == 10 then
print("i is equal to 10, so we'll skip this iteration")
-- Instead of using continue, we'll use a workaround to skip the current iteration
-- by simply not executing the following print statement
else
-- Print a message for each iteration that is not skipped or stopped
print("Iteration number " .. i .. ": I'm still going strong!")
end
-- Check if the current value of i is equal to 200
if i == 200 then
print("i has reached 200, breaking out of the loop")
break -- Exit the loop entirely when i equals 200
end
end
--[[
print("Exited the for loop")
-- A second loop that uses a while loop to demonstrate longer iteration control
local counter = 1 -- Initialize a counter variable
-- Continue looping as long as the counter is less than or equal to 10000000
while counter
i like how its just a script talking to itself, schizophrenic script lol
i made a gold mining scriptamabob using the counter he taught us
I finished this long ago but its always a good think to be back to basics! it gets overwhelming to remember simple stuff when things start to get complex.
Bro i was legit stuck on this specific problem with the loop and not running the other line and an hour later i solved it myself just to realize i couldve continued the plalist and watch your vid😢😢
Yeah, just tried the 100000 loops thing and my computer stopped responding lmaoo
I did it twice and on the last one before he changed to counter I put i already ;CCCC
I did it and it only did 5k ( i got a ryzen 5650
for i = 1, 42000 do -- third value of i statement is default as 1
if i == 10 then
print('index is currently at 10, skip this iteration')
continue
end
print("another DEAD to gang violence")
if i == 500 then
break
end
end
for i = 1, 15, 1 do -- prints after the break statement above
print("you want this to print")
end
local count = 1
while count
here's what I did!
-- The brackets and dash things disables the code
local food = 1
while food
Food aweeee
i rly fw this
Did you know that at least 9 million people have the same birthday as you?
Summary of the video:
Differences between break & continue:
continue: Used in any loop to skip the current iteration of the loop (think an iteration as the total execution count of the loop, so the first time the loop runs, its iteration count will be 1, and then 2, and then 3, ect. So, if we are in the iteration 4, and we skip the 5th iteration, it would go from 4 to 6)
Example:
for i = 1, 10 do
if i == 5 then
continue
end
print(i)
end
-- This would print: 1, 2, 3, 4, 6, 7, 8, 9, 10 (5 is skipped)
break: used to stop TOTALLY a loop, so it doesnt execute anymore and continue to the code below it.
thx
where is "8" in the last comment?
@@vsivasathvik4558 i skipped it by accident, mb, fixed
Can we use continue in while loop?
wait i didnt understand continue and you just explained it perfectly tysm
Hey i have been binge watching your playlist, your tutorials are the best and i like how you make it slow paced on the editing unlike others!
6:42 brawl when you forgot to add the break i run the script and Roblox studio stoped working for on minute and then when I checked the output it said (this while statement is printed x4994 times)
Ive been watching these in order, I think you deserve another subscriber :) thanks for help
I finished watching all your old beginner guide videos and today I saw your new beginner tutorial
You can use the Spawn() function, it basically isolates the loop so it runs with the rest of the script without waiting for the loop to finish. This can come in handy in some situations
here is what i did!!
--[[for i = 1,100000 do
if i ==10 then
print('i is equal to 10 so skip this iteration. ')
continue
end
if i== 200 then
break
end
print('this statement is printed')
end
local counter=1
while counter
i just want to say so far this is 1 of the best tutorial series ive seen so far. im not that far into it yet but you xplain things really well
*explain
@@Mystery00101 i said what i said
man this is the only playlist that actually help me memorize/learn, one time i saw a full video abt it and i forgot abt the code
This helped me a LOT learning scripting!
for i = 1, 5 do
print("Hello..")
if i == 3 then
print("skip hello and print Hi! 5 times. then continue with the last 2 Hello's")
for i = 1, 5 do
print("hi!")
end
continue
end
end
--[[testing
bracket]]
for goo = 1,100,1 do
print("counting currently")
if goo ==10 then
print("goo is now at 10")
task.wait(5)
--unanchors ball 1
workspace.greenba.Anchored=false
task.wait(1)
end
if goo ==30 then
print("goo is now at 30")
task.wait(5)
--unanchors ball 2
workspace.yellowba.Anchored=false
task.wait(1)
end
if goo >=50 then
-- im gonna make the ball fall slower on 50
print("its over 50. time to stop.")
task.wait(5)
--unanchors ball 3
workspace.Gravity = 20
workspace.redba.Anchored=false
print("wait 5 seconds for normal gravity")
task.wait(5)
workspace.Gravity= 196
print("one seconds passed. now breaked")
break
end
end
--My work
i crashed while trying to do while continue loops myself without finishing this vid :3
i found out that i forgot to make the while loops add loops
so it ran inf
I went back to the math tutorial and added some comments because I had a bit of trouble understanding.
-- For addition, it takes these 2 numbers as an example and moves on to the result variable. as you can see, its adding those 2 numbers together (example numbers)
-- Then it returns the result and ends the function. It creates a new variable and uses the addition function with 2 diffrent numbers. Thanks to the result variable, your able to add it because its taking those 2 example numbers and adding them.
-- After that its just printing the print result.
local function addition(number1, number2)
local result = number1 + number2
return result
end
local printresult = addition(8,2)
print(printresult)
local function subtraction(number1, number2)
local result = number1 - number2
return result
end
local printresult = subtraction(2, 2)
print(printresult)
local function division(number1, number2)
local result = number1 / number2
return result
end
local printresult = division(8,2)
print(printresult)
local function multiplication(number1, number2)
local result = number1 * number2
return result
end
local printresult = multiplication(2, 2)
print(printresult)
definitely best series out there. you are bringing me from tutorial hell to this master piece of tutorials
I don’t recommend nested loops for you beginners because nested loops can cause a confusion for your coding so try not to nest your coding and be one of the never nesters but do use what brawl dev shows
for “you” beginners?
@@baconheadhair6938 that was an auto but I meant it for everyone
@@baconheadhair6938 and this is a beginner tutorial so
I tried to make a nested loop, and I don't recommend doing one even if my code actually worked. It takes too long, and you need to be very careful in how you are organizing the different loops. If I hadn't known if statements, it would have been simply impossible, and I still had to use break and continue with the if statements, since something in the loops went wrong and I had to use other alternatives to end one and start the other.
for conter = 2, 100, 2 do
print("Hello")
print("Hi")
if conter == 9 then
print("hello print me")
end
if conter == 10 then
print("meow")
end
if conter == 13 then
print("Helllloooooo")
end
if conter == 14 then
print("don't skip me")
end
if conter == 16 then
print("ok stop that")
break
end
end
local zconter = 1
while zconter
Bro you are my favorite youtuber at this point you just look at my brain and answer my questions bro i finally found a tutorial that explains good and understandbly keep going your the best!
simple silly countdown
for counter = 10, 1, -1 do
if counter == 5 then
print(" 5 seconds left????")
task.wait(1)
continue
end
print(counter)
task.wait(1)
end
8:25 jokes on you I alr know about comments >:)
- loops
for s = 1, 1000000 do
- if s is 9, print
if s == 9 then
print(“this is also a string”)
continue
end
- if s is 500, stop the loop
if s == 500 then
break
end
- if none of those are met, print.
print(“this is a string”)
end
Thanks bro for this amazing vidoes and tutorial and that my script and hope anyone use it!!
--this is for loop goes through 100000 iterations until certain conditions are meet
for i = 1, 10000 do
if i == 10 then
print(" i is equal to 10 so, skip this!!")
continue
end
if i == 200 then
break
end
print("this statement is printed")
end
local counter = 1
while counter
do you know why task.wait is preferred over just wait?
Also for pepole who dont know u can coment a whole code u can select it and do ctrl / and it will coment all the script or the pice you slected
btw you can type counter += 1,insted of counter = counter =4:57
i know you know this but this is for the viewers:)
I feel like you noticed in the last vid in the comments where my script wouldn't together and this video you kinda included my comment in it XD
what is “i” anyways?
its just a variable commonly used for iteration
@@Eccotawhat’s an iteration
for i = 0, 100 do
if i % 2 == 0 then
continue
end
print("iteration number: " .. i)
end
--this while loop print only even numbers
local i = 0
while i
on the comments if you high light the code and do command question mark it'll make it a comment
Silly me forgot "counter = counter + 1" and crashed Roblox Studio😅
for k = 1,19 do
if k == 50 then -- check if current value of k is 50
print("k is equal to 19, skipping the iteration")
continue
end
print("this statement will be printed ")
end
local counter = 1
while counter
For a lot of the scripts we have done i have been adding comments as notes
for myCounter2 = 1, 5, 1 do
print("statement B")
end
end
-- For loops need 3 numbers 1. Start 2. End 3. Increment
--Nested loops lets you place loops inside loops
for i = 1, 100000 do
print("statement printed")
if i == 200 then
break
end
end
local counter = 1
while counter
-- This for loop goes through 100000 iterations until certain conditions are met
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10, so skip this iteration")
continue
end
if i == 200 then
break
end
print("this statement is printed")
end
--[[local counter = 1
while counter
This is what i did:
--This for lopp will print Brawldev 299 times
for a = 1, 100000 do
if a == 100 then
print("a = 100,skip")
continue
end
if a == 300 then
break
end
print("Brawldev is goated")
end
why task.wait(1) and not wait(1).
It's just as it is
-- ill attempt to make this change the colour of the baseplate til certain conditions are met
local baseplate = game.Workspace.Baseplate
for myCounter = 1, 100000 do
baseplate.BrickColor = BrickColor.Random()
wait(0.1)
if baseplate.BrickColor == BrickColor.new("Toothpaste") then
print("this")
continue
end
if baseplate.BrickColor == BrickColor.new("Really red") then
break
end
end
--[[
local counter = 1
while counter
I love these tutorials they explain the concepts very well but I’m always stuck asking “why would I need to know/do this” because what game needs something printed 100 times or what game needs a function to add numbers together. I love these tutorials but I wish there were more actual use application examples
-- this for loop prints 'this is for my episode #12 learning objective' once when I
-- is equal to 10 and 'keep printing me 20 times'
for i = 1, 1000 do
if i == 10 then
print("This is for my episode #12 learning objective")
continue
end
if i > 21 then
break
end
print("keep printing me")
end
for learning objective i made that :
for i = 1,5 do
local part66 = game.Workspace.part66
wait(0.1)
part66.BrickColor = BrickColor.new("Really red")
wait(0.1)
part66.BrickColor = BrickColor.new("Gold")
if i == 2 then
part66.Transparency = 1
end
if i == 2 then
break
end
end
--------------------------------------------------------------
for u = 1,10 do
if u == 6 then
print("skip this iteration")
continue -- it will not write ("hi guys") for 6 times because I wrote continue
end
if u == 7 then -- if u reaches 7 times it will stop due to using break
break
end
print("hi guys") --it will print hi guys for 5 times
end
---------------------------
for o = 1, 100 do
if o == 50 then
print("Nice Day")
continue
end
if o == 70 then
break
end
print("hello guys")
end
1:06 i thought his computer would crash (he didnt add wait to second fir loop)
I've always had a hard time learning loops- but this episode taught me so much, thanks! This is my code (don't be discouraged and don't give up! I nearly gave up myself, but always keep in mind of your ultimate goals!)
local function yourLevel ()
for i = 1,10,1 do
local LevelPrinted = math.random(1,500)
if LevelPrinted 100 and LevelPrinted 200 and LevelPrinted 300 and LevelPrinted 400 and LevelPrinted
for i = 1, 20 do
-- Check if the number is even
if i % 2 == 0 then
continue -- Skip to the next iteration if the number is even
end
-- Print the odd number
print("Number:", i)
-- Check if the number is greater than 15
if i > 15 then
print("Breaking the loop at:", i)
break -- Stop the loop if the number is greater than 15
end
end
local block = game.Workspace.Part
local function RGBPART()
print("RGBPART function started")
for i = 1, 100, 1 do
task.wait(0.25)
block.BrickColor = BrickColor.new(255, 0, 0)
task.wait(0.25)
block.BrickColor = BrickColor.new(0, 255, 0)
task.wait(0.25)
block.BrickColor = BrickColor.new(0, 0, 255)
if i == 10 then
print("Color changed 30 times!")
end
end
end
RGBPART()
for i = 1, 100 do
if i == 10 then
print("i is equal to 10, so skip this iteration")
continue
end
if i == 50 then
break
end
print("this statement is printed")
end
-- comments added for future uses, or describing something. this wont run inside scripts.
local counter = 1
while counter
Short and simple this time:
for number = 1, 50 do
if number % 2 == 0 then
print(number)
continue
end
if number >= 20 then
print("Love even numbers")
break
end
end
i made this cool loading screen in the output u guys can try it if u want:)
for myloop = 1, 10 do
if myloop == 5 then
print("Loading assets")
task.wait(1)
continue
end
if myloop == 10 then
print("Starting")
wait(5)
print("Lets go")
break
end
end
5:22 forgot to put counter = counter + 1 and it crashed lol
6:40 LMAO I TRIED TO DO THE EXAMPLE BY MYSELF AND I ALSO FORGOT TO BREAK THE SCRIPT LOLLLLL
YEES IVE BEEN WAITING
I don't think the purposes of break and continue were really articulated in this tutorial, but I guess I'll understand when the scripts get more sophisticated. My HW:
--The following code of a for loop prints 100 times, skipping the 50th iteration and stopping at the 75th
for i = 1, 100 do
if i == 50 then
print("Skip the 50th iteration")
end
if i == 75 then
print("Stop at the 75th iteration")
break
end
print("This is an iteration")
end
for i = 1, 100000 do
if math.random(1, 10) == 10 then -- skips randomly (chances are high, I don't want it to just skip once)
print("skip this iteration")
continue
end
if math.random(1, 200) == 1 then -- breaks randomly
print("the loop has stopped on loop", i)
break
end
print("there has been", i, "printed loops") -- shows the loop you are on.
end
Here's what I put.
-- Example 1
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10, so skip this iteration") -- Tells me when it reaches 10.
continue
end
if i == 50 then
break -- If it reaches 50, stop.
end
print("end of for loop")
end
-- Example 2
for i = 1, 100000 do -- This for loop goes through 100000 iterations until certain conditions are met.
if i == 10 then
print("i is equal to 10, so skip this iteration")
continue
end
if i == 20 then
break
end
print("this statement is printed")
end
-- Example 3
local counter = 1
while counter
for i = 1, 100 do
if i == 10 then
print("skip this iteration")
continue -- skip the rest of the code and go back up
end
print("Statement")
end
local counter = 0
while counter
--Conditions met to break a loop in code
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10, so thy code shall skip this iteration")
continue
end
if i == 200 then
break
end
end
local counter = 1
while counter
-- Counts up from 1 to 100
for Counter = 1, 100, 1 do
-- Mentions in an external print statement that the counter is at 25
if Counter == 25 then
print("Counter is at 25")
continue
end
-- Mentions that the counter is at 50 and breaks loop
if Counter == 50 then
print("Counter is at 50")
break
end
-- Prints the amount the counter is at (From 1 to 100 excepting 25 and 50 (stopped at 50 (I love parentheses)))
print("Counter is at "..(Counter))
end
for i = 1, 100000 do
print("this statement is printed")
if i == 10 then
print("this statement is also printed")
continue
end
if i == 200 then
break
end
end
--This for loop goes through 100000 iterations until certain conditions are met
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10 so skip this iteration")
continue
end
if i == 200 then
break
end
print("This statement is printed")
end
-- print("hello")
--[[
add
aejh
dfj
zxh
gff
]]
--[[local counter = 1
while counter
--this is my sript for loops and breaks
for a = 1, 10000 do
if a == 10 then
print("skip")
continue --here is the continue
end
if a == 300 then
print("stop")
break --here is the break
end
end
Me printing 100,000 messages watching my computer meltdown:
Me realizing it only managed to print 5,000:
To all beginners watching this tutorial
break and continue may sound pointless, but you will realize how useful they are later
for congcong = 1, 500 do
print("congcong")
if congcong == 30 then
print("congcong have 30")
continue
end
if congcong == 100 then
print("congcong is too many")
break
end
end
local abc = 1
while abc
--This loop goes through 10000 iteratiions unyil certain conditions are met.
for i = 1, 10000 do
if i == 10 then
print("i is equal to 10, so skip this iteration")
continue
end
if i == 500 then
break
end
print("This statement is printed")
if i == 200 then
break
end
end
--[[local counter = 1
while counter
Cool, now i know how break and continue works :)
heres what i did for a while loop example:
--while loop example--
local dog = 1
while dog = 100 then
print("No, it's a wolf!") --when dogVariable reaches
break -->=100 it will print this once
end --and break the code to end the
-- whole while loop.
end
--output:
--This is a dog. (x99)
--No, it's a wolf!
--[[ both 'if' statements run, but since the second reads back as false
only the first 'if' stment
will actually fire. bc it skips the second one, bc of it stating
false, but when dogVariable reaches 100, it is true and runs:
and breaks the code block after the 2nd 'if' statement code block is over. ]]
local function testcounter()
g = 0
for o = 1, 1000 do
if o == 10 then
print("O is now equal to ten")
end
if o == 400 then
break
end
if g == 100 then
g = o
print('The value of G is now equal to O = 100')
end
print('O is now equal to' ..o.."")
g = g + 1
end
for i = 1, 100000 do
if i ==10 then
print("i is equal to" .. i .. ", so skip this iteration")
end
if i == 200 then
break
end
print("This statement is printed. I =" .. i .."")
end
end
testcounter()
--ik that this is long as hell but i just want to make something that looks fancy lol
im basically writing a random script here its is:
-- using for loops
for i = 1, 1000000000000000000, 1 do
if i == 666 then
print("Skip this number, this number is horrid")
continue
end
if i == 1000 then
break
end
print("iam being printed out")
end
-- the same but using while loops
local i = 1
while i < 1000000000000000000 do
if i == 666 then
print("Skip this number, this number is horrid")
continue
end
if i == 1000 then
break
end
print("iam being printed out using while loops")
end
local a = 1
while a < 20 do -- This will repeat until a is greater than 20
print("I really like cheese")
if a == 10 then -- This will stop the loop and print something different than skip past number 11
print("I also like to eat cheese")
a = a + 2
continue
end
if a == 11 then -- if this happens then there was an error in the code and it will stop the loop
print("This was not supposed to happen....")
break
end
a = a + 1
end
-- its a loop
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10, so skip that iteration")
continue
end
if i == 100 then
print("is it working")
end
if i == 203 then
break
end
print("this statement is printed")
end
-- this loop is off
--[[local counter = 1
while counter
I combined the previous few episodes to come up with this. Also learnt a new concept with the help of gbt
Man AI is making our life easier and is letting us learn anything way faster and efficient. Imagine how hard it would be back in the 2016 days to learn how to script
local firstbreak = false
for i = 1, 1000 do
if not firstbreak and i == 100 then
print("It is 100")
firstbreak = true
end
if firstbreak and i
for hello = 1, 50 do
if hello == 14 then
print("this statement is cool")
continue
end
end
for bye = 1, 403 do
if bye == 12 then
print("this statement is good")
break
end
end
Here is what i did!
for loop = 1, 10 do
if loop == 10 then
print("loop is equal to 10, so skip this iteration!")
continue
end
print("i like eating burgers")
end
local chicken = 1
while chicken
local mywhileloop = 1
while mywhileloop
Here is a timer script using a while loop.
local counter = 1
while counter = 1 do
script.Parent.Text = counter + 1
task.wait(1)
counter = counter + 1
if counter == 10 then
break
end
end
The differences here is in the first once to not have to use a break loop I said while counter is =1 which means if I never added the break loop, it would go on forever.
I was expecting something like repeat or something. Like the baseplate color keeps changing repeatedly forever, until tell the script to stop it
here is da script if you wanna try it for urself you can:
for i = 1, 100000 do
if i == 10 then
print("i is equal to 10, so skip this iteration!")
continue
end
if i == 200 then
break
end
end
local counter = 1
while counter
i truly do not understand the concept of continue statements. i get they skip an iteration but why would i want to do that? if my break hits 200 it ends but if i have it so when it hits 20 it continues it just skips 20 in the count. like whats the point i truly dont get it
For some reason I was quite confused but in the end I understood, pretty cool stuff!
--[[
Yo this is cool,
so this is a comment
with multiple lines!
]]
--Continue
for i = 1, 69 do
if i == 10 then
print("this is 10")
continue
end
print("cool")
end
--Break
for i = 1, 200 do
print("ay, 69 times?")
if i == 69 then
break
end
end
uhh i didnt really know what to do so i just copied ur code but alternated it
for i = 1, 100000 do
if i == 15 then
print("i is equal to 15 so skip")
continue
end
if i == 1000 then
break
end
print("This statement is printed")
end
for i = 1, 1000 do
print("incremental continue to go up")
if i == 100 then
print("this incremental is set too 100")
continue
end
if i == 500 then
print("this incremental is halfway to max")
break
end
end
--[[
local counter = 1
while counter
for t = 1, 61 do
if t == 10 then
print ("You've been here for 10 seconds!")
continue
end
if t == 30 then
print ("Half a minute! Almost there!")
continue
end
if t == 60 then
print ("You've done it! Good job!")
break
end
task.wait(1)
end
--this is an amazing timer that rewards you for time
Here's what I did for the learning objective!
for airplaneCount = 1, 419 do
if airplaneCount == 100 then
print("100 airplane jackpot!!!")
continue
end
print(airplaneCount)
end
theCoolestVariable = 1
while theCoolestVariable
for Counter = 1, 10000 ,1 do
if Counter == 10 then
print("number1")
continue
end
if Counter ==50 then
print("number2")
end
print("helloooooooor")
if Counter == 500 then
break
end
end
--[[
print("hello world")
print("test41")
--]]
i already knew about comments lol i use them in almost every script
for a = 1, 100 do
--[[This will check to see if a = 10, if it does than it will say its equal to 10,
it will also check if its equal to 20 if it is than it will say its equal to 20.
If not it will continue print
]]
if a == 10 then
print("a is equal to 10!")
elseif a == 20 then
print("a is equal to 20!")
continue
end
-- This will break the print("a") loop
if a == 50 then
break
end
print("a")
end
-- This for loop goes through 100000 interations until certain condeitionps are met
for i = 1, 100000 do
if i == 1000 then
print("IT HAS PASSED ONE THOUSAND")
end
if i == 1100 then
break
end
end
thx man i love ya better then all the other videos
for number = 1, 100 do
if number % 2 ~= 0 then
continue
else
print("This is an even number.")
end
end
while true do
if true then
break
end
end