Summary: Loops are useful when we want to repeat code infinitely while the condition of the loop is true, once the condition is false, it will stop the loop and continue to the code below the loop. All loops in LUAU: - for - foripairs - forpairs - while - repeat Differences between while and repeat: 1. repeat will execute ALWAYS once before checking the condition. (like the do-while loop in other languages) 2. "while" will first check the condition, then execute the code. Differencesbetween ipairs and pairs: 1. pairs is used with dicts like: { a = true, b = false, c = "something", ....... } 2. ipairs is used with arrays (indexed with numbers), like: {1, 5, "hi", false, true} These are optional to use, but it's recommended.
7:27 "It's still going to remain as one, and never reach this criteria." me: clicks test "--and thats going to be really bad, its going to crash your gameview if you attempt to do this." me, now staring at a roblox studio window thats not responding:
LOL, its best if following along to only hit test when he does as well... There should be a stop keyboard shortcut. Most languages its cmd(mac) or cntrl(windows) ^ i think. But alt+F4 should close out studio and stop the script then reopen studio and fix the code. If that doesn't work you can always hard restart the computer
Hey guys! Quick tip: Instead of writing "myWhileCounter = myWhileCounter +1," you could write it in an easier way. Write "myWhileCounter += 1." This does the same thing as the other code, but it's a faster way of writing it. Also works for subtraction, multiplication, and division.
@AlexanderEdwards-x8e for myCounter =1, 20, 5 do print("something") end this contains: for, variable name(could be anything), = (equals to), and the numbers after it are basically starting value, end value, how much its going to count every time. in the example i gave you its going to print "something" 4 times because we start at 1, out goal is to each 20 and every time we are counting +5.
Not sure if this was already said somewhere, but 9:05 only works 5 times because his initial value was 1. If it had been set to 0 like a person normally would do it, it would run the script 6 times because the increase only happens after the while loop is ran. To avoid it possibly messing with your other code due to the initial number being 1, do not use
@AlexanderEdwards-x8e For loops will basically execute a loop of command(s) for a number of times, or indefinitely. Follow the example: 1. for myVariable = 1, 5, 1 do 2. print("Hello!") 3. end When we look at line 1, you started with the "for", which means you want a "for loop", then you defined the variable's conditions, which are, in order: 1, 5, 1 -- With the first "1" being the starting value; the "5" being the end value; and the last "1" being how much it's going to count every time the command executes and prints the "Hello!". When it has executed itself sufficient times to the starting value be equal to the end value, it will end the loop.
i made a timer & countdown with for loops local function timer(thetime) for timer= 1, thetime, 1 do print(stopwatch) task.wait(1) end end timer(5) local function countdown(thetime) for countdown = thetime, 1, -1 do print(countdown) task.wait(1) end end countdown(5) and also here is nestled loops that changes the baseplate transparency local plate = game.Workspace.Baseplate plate.Transparency = 0.5 for baseplate = 1, 5, 1 do plate.Transparency -= 0.5 print("the value has decreased!") task.wait(1) for baseplate2 = 1,5, 1 do plate.Transparency += 0.1 print("the value has increased!") task.wait(1) end end i would def say this was actually like the BEST and FUN tutorial/episode by far in this series
question: when do you think this series is going to be over? if the series ends i might unknowingly just wait for another part to come out leaving the advanced and gui series untouched because i feel like i didnt finish this one. also, ive been looking for such simple yet working guides! thank you!
It's about 18-19 episodes. I won't be remaking the advanced and gui series so it's up to you. You can either wait till all episodes come out or watch the older 2023 beginner series. I recommend waiting for all episodes to come out.
Thanks to your series I decided to challenge myself by making a little minigame! Took a lot of thinking and bug fixing but I did it! I am well aware this code could be cleaner but I haven't gotten to tables yet. This is a simple minigame where 3 of 4 parts turn red and dissapear and your goal is to jump to the one platform that stays before the other dissapear. The game gets faster overtime and maxes out at a 1 second per round. Note: The script and parts are in a folder called Parts local part1 = script.Parent.Part1 local part2 = script.Parent.Part2 local part3 = script.Parent.Part3 local part4 = script.Parent.Part4 local timer = 3 local function STAGE4() part1.BrickColor = BrickColor.new("Really red") part2.BrickColor = BrickColor.new("Really red") part3.BrickColor = BrickColor.new("Really red") task.wait(timer) part1.Transparency = 1 part1.CanCollide = false part2.Transparency = 1 part2.CanCollide = false part3.Transparency = 1 part3.CanCollide = false task.wait(timer) end local function STAGE1() part4.BrickColor = BrickColor.new("Really red") part2.BrickColor = BrickColor.new("Really red") part3.BrickColor = BrickColor.new("Really red") task.wait(timer) part4.Transparency = 1 part4.CanCollide = false part2.Transparency = 1 part2.CanCollide = false part3.Transparency = 1 part3.CanCollide = false task.wait(timer) end local function STAGE3() part1.BrickColor = BrickColor.new("Really red") part2.BrickColor = BrickColor.new("Really red") part4.BrickColor = BrickColor.new("Really red") task.wait(timer) part1.Transparency = 1 part1.CanCollide = false part2.Transparency = 1 part2.CanCollide = false part4.Transparency = 1 part4.CanCollide = false task.wait(timer) end local function STAGE2() part1.BrickColor = BrickColor.new("Really red") part4.BrickColor = BrickColor.new("Really red") part3.BrickColor = BrickColor.new("Really red") task.wait(timer) part1.Transparency = 1 part1.CanCollide = false part4.Transparency = 1 part4.CanCollide = false part3.Transparency = 1 part3.CanCollide = false task.wait(timer) end local function RESET() part1.BrickColor = BrickColor.new("Medium stone grey") part2.BrickColor = BrickColor.new("Medium stone grey") part3.BrickColor = BrickColor.new("Medium stone grey") part4.BrickColor = BrickColor.new("Medium stone grey") part1.Transparency = 0 part1.CanCollide = true part2.Transparency = 0 part2.CanCollide = true part3.Transparency = 0 part3.CanCollide = true part4.Transparency = 0 part4.CanCollide = true task.wait(timer) end function Subtract() if timer > 0.5 then timer = timer - 0.5 else timer = 0.5 end
end while true do STAGE1() RESET() Subtract() STAGE3() RESET() Subtract() STAGE2() RESET() Subtract() STAGE4() RESET() Subtract() end
@MisMatch1234 i really liked your minigame alot and i made something simillar but stages are random local part1 = script.Parent.Part1 local part2 = script.Parent.Part2 local part3 = script.Parent.Part3 local part4 = script.Parent.Part4 local timer = 3 local function reset() part1.BrickColor = BrickColor.Black() part2.BrickColor = BrickColor.Black() part3.BrickColor = BrickColor.Black() part4.BrickColor = BrickColor.Black() part1.Transparency = 0 part2.Transparency = 0 part3.Transparency = 0 part4.Transparency = 0 wait(timer) end local function stages() local rng = math.random(1,4) if rng == 1 then part1.BrickColor = BrickColor.Red() part2.BrickColor = BrickColor.Red() part3.BrickColor = BrickColor.Red() wait(timer) part1.Transparency = 1 part2.Transparency = 1 part3.Transparency = 1
wait(timer) elseif rng == 2 then part1.BrickColor = BrickColor.Red() part2.BrickColor = BrickColor.Red() part4.BrickColor = BrickColor.Red() wait(timer) part1.Transparency = 1 part2.Transparency = 1 part4.Transparency = 1 wait(timer) elseif rng == 3 then part2.BrickColor = BrickColor.Red() part3.BrickColor = BrickColor.Red() part4.BrickColor = BrickColor.Red() wait(timer) part2.Transparency = 1 part3.Transparency = 1 part4.Transparency = 1 wait(timer) elseif rng == 4 then part1.BrickColor = BrickColor.Red() part3.BrickColor = BrickColor.Red() part4.BrickColor = BrickColor.Red() wait(timer) part1.Transparency = 1 part3.Transparency = 1 part4.Transparency = 1 wait(timer) end end local function subtract() if timer > 0.5 then timer = timer - 0.5 else timer = 0.5 end end while true do stages() reset() subtract() end
Man, this guy's videos are getting fewer and fewer views. Between his first video and this one, many people have already left (there are still those who are determined and patient)
guys can someone please help me with the for loops part cuz i really dont understand the explanation of having the three numbers like i dont know whats the point of them no matter how many times i rewatch the video. 😔😭
I'm just skimming through this video since I just need a refresher on lua but this is a cool for loop exercise that makes a square -- Nested for loop for row = 1,10 do -- Will iterate 10 times (simulating 10 rows) for column = 1,10 do -- Will iterate 10 except this time its columns local part = Instance.new("Part") -- This is just how you make a part part.Parent = workspace part.Anchored = true part.Size = Vector3.new(1,1,1) -- Size is set to a 1x1 cube to make positioning easier part.Position = Vector3.new(row,0,column) end end
@@eyadosama4381 Vector is position, Anchored means wether the object is unmovable or movable, or let just say anchored. Instance means creating something
im still not very good but here is what i made: local baseplate = game.Workspace.Baseplate task.wait(2) print("what is happening?") baseplate.BrickColor = BrickColor.new("Bright orange") task.wait(2) print("It's changing colour!") baseplate.BrickColor = BrickColor.new("Really red") task.wait(2) print("Is it over?") task.wait(2) baseplate.Anchored = false task.wait(1) print("WE ARE FALLING!")
i made another one! local part = game.Workspace.Part for myCounter = 1, 100, 1 do part.BrickColor = BrickColor.new("Really red") task.wait(0.1) part.BrickColor = BrickColor.new("Neon orange") task.wait(0.1) part.BrickColor = BrickColor.new("New Yeller") task.wait(0.1) end
i put this inside a baseplate while true do script.Parent.BrickColor = BrickColor.new("Gold") task.wait(1) script.Parent.BrickColor = BrickColor.new("Silver") task.wait(1) script.Parent.BrickColor = BrickColor.new("Copper") task.wait(1) end
local baseplate = game.Workspace.Baseplate local colourChanger = 1 while colourChanger == 1 do baseplate.BrickColor = BrickColor.Random() task.wait(1) end This series is awesome! Thank you so much it's helped immensely!
To add on to this, I learned about touched functions myself, and made it so that it stops changing colour when you touch it :) local baseplate = game.Workspace.Baseplate local colourChanger = 1 local function touchyTouch() colourChanger = colourChanger + 1 end baseplate.Touched:Connect(touchyTouch) while colourChanger == 1 do baseplate.BrickColor = BrickColor.Random() task.wait(0.5) end
-- Randomizes baseplate color and counts how many randomizations have happendd and prints them. local baseplate = game.Workspace.Baseplate counter = 0 while true do counter = counter + 1 print('Color ',counter) -- Inner loop for i = 1, 10 do red = math.random(1, 255) green = math.random(1, 255) blue = math.random(1, 255) baseplate.Color = Color3.new(red,green,blue) end wait(1) end
For the learning objective I did: basePlate = game.Workspace.Baseplate while true do -- While true does a infinite loop which could be useful red = math.random(1,255) -- uses math.random for a pseudo randomization of the rgb coordinate green = math.random(1,255) blue = math.random(1,255) basePlate.Color = Color3.new(red,green,blue) -- places in the randomizations of the rgb coords to generate random colors task.wait(0.5) -- has to wait so that the code doesn't break and stops at one color. end
The last number is the number that your for loop increments by. Like the one BrawlDev showed us 1, 5, 1. You start on the number 1 and end on 5. Number 1 at the end is how much the for loop increases by each time. If you made that a 2 it wouldn't work because 2 can't be divided into 5. I hope this helps!
Quick explanation: I made a lava texture object which i called "MagmaPart", which i used to test my loops. local cube = game.Workspace.MagmaPart local counter = 1 while counter < 2 do cube.BrickColor = BrickColor.new("Really red") task.wait(1) for counter2 = 1, 10, 2 do cube.Material = "Marble" task.wait(1) cube.Material = "Basalt" task.wait(1) end cube.BrickColor = BrickColor.new("Toothpaste") wait(1) end
just a small tip i learnt from java, instead of doing myWhileCounter = myWhileCounter + 1, you can actually just do myWhileCounter += 1, which means the exact same thing :)
i put a script in a part that makes the part disappear and reappear like in a timed jump minigame while true do script.Parent.Transparency = 0 script.Parent.CanCollide = true task.wait(0.35) script.Parent.Transparency = 1 script.Parent.CanCollide = false task.wait(0.35) end
Since I had a bit of trouble learning the for loop, ill explain it here, the second number is how many times the loop will go BUT, the third number tells how many increments it goes it, and the first number is the number it begins at, for example "for myCount 0.5, 5, 0.5" the first number is the number it begins at, then the third number is how much it goes up each time until it reached the second number, in this case, the loop goes 10 times
local myWhileCounter = 1 while myWhileCounter >= 5 do print("Crazy?") task.wait(0.5) print("I was crazy once") task.wait(0.5) print("They locked me in a room") task.wait(0.5) print("A rubber room") task.wait(0.5) print("A rubber room with rats") task.wait(0.5) print("And rats make me crazy") task.wait(0.5) myWhileCounter = myWhileCounter+1 end
Dudeeee tysm i made a gambling game where there everytime you join there is a 4/5 chance to kick you with a bruh sound effect and a 1/5 you stay and it will spawn a bunch ofgreen bricks (money) on the spawnpoint with register sounds for like 10 seconds and then kicks you saying something like “you won” i used your vids in combination with google searches and dev forum
I’ve started kinda skipping through this series because I already know most of the basic computer science, I’m just wondering when he’ll get into user input / player interaction. Because most scripts aren’t very useful if there’s no way for a player to interact with/trigger them
If anyone was wondering heres what I've learned after watching the video- Making and infinitely color changing cube. local Cube = script.Parent wait(5) while true do for cubeColor = 1, 1, 1 do Cube.BrickColor = BrickColor.new("Really red") task.wait(0.5) Cube.BrickColor = BrickColor.new("Neon orange") task.wait(0.5) Cube.BrickColor = BrickColor.new("New Yeller") task.wait(0.5) Cube.BrickColor = BrickColor.new("Lime green") task.wait(0.5) Cube.BrickColor = BrickColor.new("Bright blue") task.wait(0.5) Cube.BrickColor = BrickColor.new("Royal purple") task.wait(0.5) end end
Also for the while true do you can just put a task.wait(any number that isnt too low here) before your script to prevent it from crashing if you want to make an indefinite loop for some reason but it will still crash eventually if your script is like an instance.new(“part”) and wont destroy any old parts
In Lua programming, print is a built-in function that is used to output data to the console or standard output. It allows developers to display values, messages, or other types of information during the execution of a program.
I made a script that makes the baseplate smoothly blink from transparent to non transparent like this: local baseplate = game.Workspace.Baseplate for MyCounter = 1, 10, 1 do for Counter = 1, 10, 1 do baseplate.Transparency = baseplate.Transparency + 0.1 task.wait(0.1) end for Counter2 = 1, 10, 1 do baseplate.Transparency = baseplate.Transparency - 0.1 task.wait(0.1) end end you can try it out yourself if you want :D
with what i learned i did this countdown (also i did the loop mechanic so is changable ez) for countdown = 3, 3, 3 do print("3") wait(1) print("2") wait(1) print("1") wait(1) do print("go") end end (I didnt include while since i cant think of a scenario with it)
6:48 when i did this, i wanted to test it and i didnt listen to the warning, but when i realized the number cant change my roblox studio crashed becuase it made infinite loop woopsies
I went kinda crazy with this one... Its a part that will change color in a rainbow order and within each color change, it changes the material 9 times within 3 materials and the colour in rainbow order happens 60 times I think it changes a total of 540 times if my math is right... sooo let me just show it 😄 local part = game.Workspace.Part for myCounter = 1, 10, 1 do part.BrickColor = BrickColor.new("Really red") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end part.BrickColor = BrickColor.new("Neon orange") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end part.BrickColor = BrickColor.new("New Yeller") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end part.BrickColor = BrickColor.new("Lime green") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end part.BrickColor = BrickColor.new("Deep blue") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end part.BrickColor = BrickColor.new("Royal purple") task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end end
this part repeats a lot so you could make it a function to shorten your script task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) Ex: local part = game.Workspace.Part local function myFunction() task.wait(1) for myCounter2 = 1, 3, 1 do part.Material = Enum.Material.Neon task.wait(1) part.Material = Enum.Material.Wood task.wait(1) part.Material = Enum.Material.CrackedLava task.wait(1) end end for myCounter = 1, 10, 1 do part.BrickColor = BrickColor.new("Really red") myFunction() part.BrickColor = BrickColor.new("Neon orange") myFunction() part.BrickColor = BrickColor.new("New Yeller") myFunction() part.BrickColor = BrickColor.new("Lime green") myFunction() part.BrickColor = BrickColor.new("Deep blue") myFunction() part.BrickColor = BrickColor.new("Royal purple") myFunction() end
BrawlDev the teacher we never asked for but need this whole time you have earned a sub and here's my learning objective. local sphere = game.Workspace.RGB for myCounter = 1, 10, 1 do sphere.BrickColor = BrickColor.new("Really red") print("woah im red") wait(2) sphere.BrickColor = BrickColor.new("Really blue") print("woah now im blue") wait(2) sphere.BrickColor = BrickColor.new("Lime green") print("wow grass") wait(2) sphere.Material = "LeafyGrass" print("YAY IM GRASS NOW") wait(2) sphere.Material = "Plastic" sphere.BrickColor = BrickColor.new("Pink") print("IM A PREPPY PRINCESS NOW") end
local rizz = game.Workspace.rizz local fp = game.Workspace.FunctionPart for change = 1, 2, 1 do fp.BrickColor = BrickColor.Random() task.wait(1) for secondChange = 1, 12, 1 do rizz.BrickColor = BrickColor.Random() task.wait(1) print("Working!") task.wait(1) end end
a script that just changes a part and loops local msg = game.Workspace.Part local r = game.Workspace.Part local e = game.Workspace.Part local s = game.Workspace.Part local d = game.Workspace.Part local n = game.Workspace.Part msg.Material = "Grass" wait(3) r.Material = "Metal" wait(2) e.Material = "Mud" wait(2) s.Material = "Leather" wait(2) d.Material = "Snow" wait(2) n.Material = "Neon" wait(1) for mc = 10, 10 , 10 do print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") print("y") end local myh = 1 while myh
for Clant = 1, 1000, 1 do print('you completed lesson goal for episode 11; this will repeat every second') task.wait(1) print("thsi is used to prevent the out from using ###(x#) format") task.wait(1) end
W vid, learned a lot today. Heres what I made: local baseplate = game.Workspace.Baseplate for myCounter = 1, 10, 1 do baseplate.BrickColor = BrickColor.new("Lime green") baseplate.Transparency = 0.8 task.wait(1) baseplate.BrickColor = BrickColor.new("Toothpaste") baseplate.Transparency = 0 task.wait(1)
for myCounter2 = 1, 3, 1 do baseplate.Material = "Pebble" task.wait(1) baseplate.Material = "Limestone" end end
I used loops, functions and if statement to change the objects transparencty. First I changed it with for loops then with while loops. Here is the script if you want to test and check it out: local testObject = game.Workspace.TestObject local test = 0 local test2 = 0 local function changeTransparency(value) testObject.Transparency = testObject.Transparency + value end for i = 1, 10, 1 do changeTransparency(0.1) wait(0.1) if i == 10 then print("Object is transparent, changing back") wait(3) for i2 = 1, 10, 1 do changeTransparency(-0.1) wait(0.1) end end end print("Your object is now visible, proceeding to do the same with while loop") wait(3) while test
not sure if i did enough but i should definitely practice this anyways: for myCounter = 1, 3, 1 do print("For every time this statement is stated, another statement is stated 5 times") for myCounter2 = 1, 5, 1 do print("The statement above is correct") end end local auraLevel = 1000 while auraLevel 9000 then print("HIS POWER LEVEL IS OVER 9000") end end
My homework makes a part slow fade away, becoming intangible when it is invisible: local part = game.Workspace.Part while part.Transparency 1 then part.CanCollide = false end end
3rd num +/- 1st num so, completes a loop and it plus 1 till it reaches 5, or at 9:55 3rd num is -1 so it -1 from 5 till it reaches 1. Hope it makes sense
Yippee, we are back to messing with the in-game object and not just the output! :D (output was fun too, but I was getting tired of it) My LO: local lava = game.Workspace.CrackedLavaPart local someVariable = 1 local marble = game.Workspace.MarblePart local function animateLava() while someVariable
I am loving these episodes, they are so easy to understand. Here are my scripts btw, and what i did was i made multiple different items in my world to keep changing colors infinitely. I made them the same colors though, so they were aligned in the same pattern. local plate = game.Workspace.Baseplate while 1 == 1 do plate.BrickColor = BrickColor.new("Lapis") wait (0.2) plate.BrickColor = BrickColor.new("Toothpaste") wait (0.2) plate.BrickColor = BrickColor.new("Lime green") wait (0.2) plate.BrickColor = BrickColor.new("Deep orange") wait (0.2) plate.BrickColor = BrickColor.new("Really red") wait (0.2) end -------------- local part = game.Workspace.ThePart while 1 == 1 do part.BrickColor = BrickColor.new("Lapis") wait (0.2) part.BrickColor = BrickColor.new("Toothpaste") wait (0.2) part.BrickColor = BrickColor.new("Lime green") wait (0.2) part.BrickColor = BrickColor.new("Deep orange") wait (0.2) part.BrickColor = BrickColor.new("Really red") wait (0.2) end ------------- local spawnpoint = game.Workspace.SpawnLocation while 1 == 1 do spawnpoint.BrickColor = BrickColor.new("Lapis") wait (0.2) spawnpoint.BrickColor = BrickColor.new("Toothpaste") wait (0.2) spawnpoint.BrickColor = BrickColor.new("Lime green") wait (0.2) spawnpoint.BrickColor = BrickColor.new("Deep orange") wait (0.2) spawnpoint.BrickColor = BrickColor.new("Really red") wait (0.2) end
Got back to this tutorial after a bit, here's what I wrote: for myCounter = 1, 5, 1 do print("A") for myCounter2 = 1, 5, 1 do print("B") end end local myWhileCounter = 1 while myWhileCounter
local red = game.Workspace.policeRed local blue = game.Workspace.policeBlue local function alternatingLights() red.Transparency = 0.8 if red.Transparency >= 0.8 then blue.Transparency = 0 blue.Material = "Neon"
end wait(0.5) if red.Transparency >= 0.8 then red.Transparency = 0 red.Material = "Neon" blue.Material = "Plastic" blue.Transparency = 0.8 end wait(0.5) if blue.Transparency >= 0.8 then red.Transparency = 0.8 end
end for lightChange = 1, 10000000, 1 do alternatingLights() end this code is used to make two blocks one red and one blue switch between on and off to simulate a police siren effect love ur videos man
changed the material local baseplate = game.Workspace.Baseplate for mC = 1, 100,1 do baseplate.Material = "Limestone" task.wait(1) baseplate.Material = "Marble" task.wait(1) baseplate.Material = "Plastic" task.wait(1) end
expanded a bit on the script in the video, just made a function with a while loop that goes from 1 to 5, changing the color of the baseplate to a random color every .2 seconds, then sets the whilecounter back to 1. then i put this function in between each of our previously stated for loop, making it a function nested loop? idk but its fun. local baseplate = game.Workspace.Baseplate local whileCounter = 1 local function RandomFast() while whileCounter < 5 do baseplate.BrickColor = BrickColor.random() task.wait(0.2) whileCounter = whileCounter + 1 end whileCounter = 1 end for myCounter = 1, 10, 1 do
Summary:
Loops are useful when we want to repeat code infinitely while the condition of the loop is true, once the condition is false, it will stop the loop and continue to the code below the loop.
All loops in LUAU:
- for
- foripairs
- forpairs
- while
- repeat
Differences between while and repeat:
1. repeat will execute ALWAYS once before checking the condition. (like the do-while loop in other languages)
2. "while" will first check the condition, then execute the code.
Differencesbetween ipairs and pairs:
1. pairs is used with dicts like: { a = true, b = false, c = "something", ....... }
2. ipairs is used with arrays (indexed with numbers), like: {1, 5, "hi", false, true}
These are optional to use, but it's recommended.
thx
We didn't learn repeat, ipars and pairs, do we learn that in a future class?
@@SimplyTutuco i guess so
@@SimplyTutuco you will learn them in tables beginners tutorials basically
Question, I understand while loops but not the for loops, can someone explain them to me in plain English?
7:27 "It's still going to remain as one, and never reach this criteria."
me: clicks test
"--and thats going to be really bad, its going to crash your gameview if you attempt to do this."
me, now staring at a roblox studio window thats not responding:
Same 😂😂😂
LOL, its best if following along to only hit test when he does as well...
There should be a stop keyboard shortcut. Most languages its cmd(mac) or cntrl(windows) ^ i think. But alt+F4 should close out studio and stop the script then reopen studio and fix the code. If that doesn't work you can always hard restart the computer
SKIBIDO
same LOL
Literally me, tho I used while true do for fun. Without a wait.
Hey guys! Quick tip:
Instead of writing "myWhileCounter = myWhileCounter +1," you could write it in an easier way.
Write "myWhileCounter += 1." This does the same thing as the other code, but it's a faster way of writing it. Also works for subtraction, multiplication, and division.
goat
Question, I understand while loops but not the for loops, can someone explain them to me in plain English?
@AlexanderEdwards-x8e
for myCounter =1, 20, 5 do
print("something")
end
this contains: for, variable name(could be anything), = (equals to), and the numbers after it are basically starting value, end value, how much its going to count every time.
in the example i gave you its going to print "something" 4 times because we start at 1, out goal is to each 20 and every time we are counting +5.
LETS GO I MADE A COLOR CHANGING CUBE!! IM PROUD OF MYSELFT THANK YOU
how did you make that this episode was a bit confusing for me
@@rafaeldossantos1998watch the video and copy every line of code he does and try doing what he did
@@rafaeldossantos1998 he wrote the same script but instead .Baseplate , he did .part
It’s really easy to do by watching his videos, Atleast he is not that RUclipsr that just talks about apples every video when scripting
Yo same! It even crash the first time!
this was the hardest tutorial to understand but i did get the hang of it
true
Not sure if this was already said somewhere, but 9:05 only works 5 times because his initial value was 1. If it had been set to 0 like a person normally would do it, it would run the script 6 times because the increase only happens after the while loop is ran.
To avoid it possibly messing with your other code due to the initial number being 1, do not use
Question, I understand while loops but not the for loops, can someone explain them to me in plain English?
@AlexanderEdwards-x8e For loops will basically execute a loop of command(s) for a number of times, or indefinitely. Follow the example:
1. for myVariable = 1, 5, 1 do
2. print("Hello!")
3. end
When we look at line 1, you started with the "for", which means you want a "for loop", then you defined the variable's conditions, which are, in order:
1, 5, 1 -- With the first "1" being the starting value; the "5" being the end value; and the last "1" being how much it's going to count every time the command executes and prints the "Hello!".
When it has executed itself sufficient times to the starting value be equal to the end value, it will end the loop.
The way you explain things makes it very easy to understand even complicated topics. (thank you BrawlDev)
I've watched a bunch of scripting videos for LUA. Your tutorials are the best by far! Keep up the great work man. I appreciate you!🥇
not mentioning the ''while true do'' loop is a crime
yes, I was bouta say. that's like the only one I knew how to do previously to these videos lol
@@Isostraight that's the only thing at all I knew how to do before this
It's the same as defining any variable to true and doing
while ThatOneVariable = true do
He doesn't need to, true and false are just other data type that can be used within a while loop.
Bro from all the youtuber who are teaching your are from far the best at explaining keep it up dude
i made a timer & countdown with for loops
local function timer(thetime)
for timer= 1, thetime, 1 do
print(stopwatch)
task.wait(1)
end
end
timer(5)
local function countdown(thetime)
for countdown = thetime, 1, -1 do
print(countdown)
task.wait(1)
end
end
countdown(5)
and also here is nestled loops that changes the baseplate transparency
local plate = game.Workspace.Baseplate
plate.Transparency = 0.5
for baseplate = 1, 5, 1 do
plate.Transparency -= 0.5
print("the value has decreased!")
task.wait(1)
for baseplate2 = 1,5, 1 do
plate.Transparency += 0.1
print("the value has increased!")
task.wait(1)
end
end
i would def say this was actually like the BEST and FUN tutorial/episode by far in this series
question: when do you think this series is going to be over?
if the series ends i might unknowingly just wait for another part to come out leaving the advanced and gui series untouched because i feel like i didnt finish this one.
also, ive been looking for such simple yet working guides! thank you!
It's about 18-19 episodes. I won't be remaking the advanced and gui series so it's up to you. You can either wait till all episodes come out or watch the older 2023 beginner series. I recommend waiting for all episodes to come out.
@@BrawlDevRBLX ok
I love your videos man keep up the good work
I've been using studio for a couple months now and I can tell you, I almost ALWAYS forget to at least put a wait in my while loop 😅
i made a traffic light!!!
Glad to hear.
Thanks man I’ve been trying to make my own Roblox game and this is helping so much I remember everything and it’s actually easy
Thanks to your series I decided to challenge myself by making a little minigame! Took a lot of thinking and bug fixing but I did it! I am well aware this code could be cleaner but I haven't gotten to tables yet. This is a simple minigame where 3 of 4 parts turn red and dissapear and your goal is to jump to the one platform that stays before the other dissapear. The game gets faster overtime and maxes out at a 1 second per round.
Note: The script and parts are in a folder called Parts
local part1 = script.Parent.Part1
local part2 = script.Parent.Part2
local part3 = script.Parent.Part3
local part4 = script.Parent.Part4
local timer = 3
local function STAGE4()
part1.BrickColor = BrickColor.new("Really red")
part2.BrickColor = BrickColor.new("Really red")
part3.BrickColor = BrickColor.new("Really red")
task.wait(timer)
part1.Transparency = 1
part1.CanCollide = false
part2.Transparency = 1
part2.CanCollide = false
part3.Transparency = 1
part3.CanCollide = false
task.wait(timer)
end
local function STAGE1()
part4.BrickColor = BrickColor.new("Really red")
part2.BrickColor = BrickColor.new("Really red")
part3.BrickColor = BrickColor.new("Really red")
task.wait(timer)
part4.Transparency = 1
part4.CanCollide = false
part2.Transparency = 1
part2.CanCollide = false
part3.Transparency = 1
part3.CanCollide = false
task.wait(timer)
end
local function STAGE3()
part1.BrickColor = BrickColor.new("Really red")
part2.BrickColor = BrickColor.new("Really red")
part4.BrickColor = BrickColor.new("Really red")
task.wait(timer)
part1.Transparency = 1
part1.CanCollide = false
part2.Transparency = 1
part2.CanCollide = false
part4.Transparency = 1
part4.CanCollide = false
task.wait(timer)
end
local function STAGE2()
part1.BrickColor = BrickColor.new("Really red")
part4.BrickColor = BrickColor.new("Really red")
part3.BrickColor = BrickColor.new("Really red")
task.wait(timer)
part1.Transparency = 1
part1.CanCollide = false
part4.Transparency = 1
part4.CanCollide = false
part3.Transparency = 1
part3.CanCollide = false
task.wait(timer)
end
local function RESET()
part1.BrickColor = BrickColor.new("Medium stone grey")
part2.BrickColor = BrickColor.new("Medium stone grey")
part3.BrickColor = BrickColor.new("Medium stone grey")
part4.BrickColor = BrickColor.new("Medium stone grey")
part1.Transparency = 0
part1.CanCollide = true
part2.Transparency = 0
part2.CanCollide = true
part3.Transparency = 0
part3.CanCollide = true
part4.Transparency = 0
part4.CanCollide = true
task.wait(timer)
end
function Subtract()
if timer > 0.5 then
timer = timer - 0.5
else
timer = 0.5
end
end
while true do
STAGE1()
RESET()
Subtract()
STAGE3()
RESET()
Subtract()
STAGE2()
RESET()
Subtract()
STAGE4()
RESET()
Subtract()
end
I am actually so proud of myself for this even though it isn't much (:
@MisMatch1234 it is really cool! dont give up, the only thing i dont understand is why stage 4 is before stage 1, but other than that a great code!
@MisMatch1234 i really liked your minigame alot and i made something simillar but stages are random
local part1 = script.Parent.Part1
local part2 = script.Parent.Part2
local part3 = script.Parent.Part3
local part4 = script.Parent.Part4
local timer = 3
local function reset()
part1.BrickColor = BrickColor.Black()
part2.BrickColor = BrickColor.Black()
part3.BrickColor = BrickColor.Black()
part4.BrickColor = BrickColor.Black()
part1.Transparency = 0
part2.Transparency = 0
part3.Transparency = 0
part4.Transparency = 0
wait(timer)
end
local function stages()
local rng = math.random(1,4)
if rng == 1 then
part1.BrickColor = BrickColor.Red()
part2.BrickColor = BrickColor.Red()
part3.BrickColor = BrickColor.Red()
wait(timer)
part1.Transparency = 1
part2.Transparency = 1
part3.Transparency = 1
wait(timer)
elseif rng == 2 then
part1.BrickColor = BrickColor.Red()
part2.BrickColor = BrickColor.Red()
part4.BrickColor = BrickColor.Red()
wait(timer)
part1.Transparency = 1
part2.Transparency = 1
part4.Transparency = 1
wait(timer)
elseif rng == 3 then
part2.BrickColor = BrickColor.Red()
part3.BrickColor = BrickColor.Red()
part4.BrickColor = BrickColor.Red()
wait(timer)
part2.Transparency = 1
part3.Transparency = 1
part4.Transparency = 1
wait(timer)
elseif rng == 4 then
part1.BrickColor = BrickColor.Red()
part3.BrickColor = BrickColor.Red()
part4.BrickColor = BrickColor.Red()
wait(timer)
part1.Transparency = 1
part3.Transparency = 1
part4.Transparency = 1
wait(timer)
end
end
local function subtract()
if timer > 0.5 then
timer = timer - 0.5
else
timer = 0.5
end
end
while true do
stages()
reset()
subtract()
end
@ Ty! A I am almost to the random tutorial and I was planning on making it random once I got there! Glad you liked it!
@Filaaaa it just changes the order a bit
congrats on almost 30k subs!!
what does the 3 number on the right do in the for while loop
i will watch the video and hopfully i can awnser you
Man, this guy's videos are getting fewer and fewer views. Between his first video and this one, many people have already left (there are still those who are determined and patient)
finally a actually good tutorial series
guys can someone please help me with the for loops part cuz i really dont understand the explanation of having the three numbers like i dont know whats the point of them no matter how many times i rewatch the video. 😔😭
U don't need more than 1 I dunno why he did that
I'm just skimming through this video since I just need a refresher on lua but this is a cool for loop exercise that makes a square
-- Nested for loop
for row = 1,10 do -- Will iterate 10 times (simulating 10 rows)
for column = 1,10 do -- Will iterate 10 except this time its columns
local part = Instance.new("Part") -- This is just how you make a part
part.Parent = workspace
part.Anchored = true
part.Size = Vector3.new(1,1,1) -- Size is set to a 1x1 cube to make positioning easier
part.Position = Vector3.new(row,0,column)
end
end
calm down we still dont know these things😐
@@eyadosama4381 Vector is position, Anchored means wether the object is unmovable or movable, or let just say anchored. Instance means creating something
Also thankyou so much for making this tutorials its so helpfull
making the baseplate change colors is really fun
Thanks! i rlly love what i have done just now!!!!
im still not very good but here is what i made:
local baseplate = game.Workspace.Baseplate
task.wait(2)
print("what is happening?")
baseplate.BrickColor = BrickColor.new("Bright orange")
task.wait(2)
print("It's changing colour!")
baseplate.BrickColor = BrickColor.new("Really red")
task.wait(2)
print("Is it over?")
task.wait(2)
baseplate.Anchored = false
task.wait(1)
print("WE ARE FALLING!")
i made another one!
local part = game.Workspace.Part
for myCounter = 1, 100, 1 do
part.BrickColor = BrickColor.new("Really red")
task.wait(0.1)
part.BrickColor = BrickColor.new("Neon orange")
task.wait(0.1)
part.BrickColor = BrickColor.new("New Yeller")
task.wait(0.1)
end
i put this inside a baseplate
while true do
script.Parent.BrickColor = BrickColor.new("Gold")
task.wait(1)
script.Parent.BrickColor = BrickColor.new("Silver")
task.wait(1)
script.Parent.BrickColor = BrickColor.new("Copper")
task.wait(1)
end
you don't need to write "task" just write wait()
@@domakrsnah1612 wait is actually deprecated, but I only discover it now
@@domakrsnah1612 either ways they're the same I guess
local baseplate = game.Workspace.Baseplate
local colourChanger = 1
while colourChanger == 1 do
baseplate.BrickColor = BrickColor.Random()
task.wait(1)
end
This series is awesome! Thank you so much it's helped immensely!
To add on to this, I learned about touched functions myself, and made it so that it stops changing colour when you touch it :)
local baseplate = game.Workspace.Baseplate
local colourChanger = 1
local function touchyTouch()
colourChanger = colourChanger + 1
end
baseplate.Touched:Connect(touchyTouch)
while colourChanger == 1 do
baseplate.BrickColor = BrickColor.Random()
task.wait(0.5)
end
Just asking why would you need all of the different types if they all do the same thing?
Coding is a logical computer language. Who knows what problem may occur, more option is better for that case in my opinion
-- Randomizes baseplate color and counts how many randomizations have happendd and prints them.
local baseplate = game.Workspace.Baseplate
counter = 0
while true do
counter = counter + 1
print('Color ',counter)
-- Inner loop
for i = 1, 10 do
red = math.random(1, 255)
green = math.random(1, 255)
blue = math.random(1, 255)
baseplate.Color = Color3.new(red,green,blue)
end
wait(1)
end
Thank you! What I learned today was that I shouldn't have put 9.99e+9999 in the repeat loop in an attempt to replicate a forever loop like in scratch!
My fav episode so far. I was so surprised when he said, "wait statement". Like my face was literally 😯
For the learning objective I did:
basePlate = game.Workspace.Baseplate
while true do -- While true does a infinite loop which could be useful
red = math.random(1,255) -- uses math.random for a pseudo randomization of the rgb coordinate
green = math.random(1,255)
blue = math.random(1,255)
basePlate.Color = Color3.new(red,green,blue) -- places in the randomizations of the rgb coords to generate random colors
task.wait(0.5) -- has to wait so that the code doesn't break and stops at one color.
end
hey brawldev can you explain a little more about the last number on the for myCounter = 1, 5, 1
The last number is the number that your for loop increments by. Like the one BrawlDev showed us 1, 5, 1. You start on the number 1 and end on 5. Number 1 at the end is how much the for loop increases by each time. If you made that a 2 it wouldn't work because 2 can't be divided into 5. I hope this helps!
Quick explanation: I made a lava texture object which i called "MagmaPart", which i used to test my loops.
local cube = game.Workspace.MagmaPart
local counter = 1
while counter < 2 do
cube.BrickColor = BrickColor.new("Really red")
task.wait(1)
for counter2 = 1, 10, 2 do
cube.Material = "Marble"
task.wait(1)
cube.Material = "Basalt"
task.wait(1)
end
cube.BrickColor = BrickColor.new("Toothpaste")
wait(1)
end
commenting just to boost your channel
just a small tip i learnt from java, instead of doing myWhileCounter = myWhileCounter + 1, you can actually just do myWhileCounter += 1, which means the exact same thing :)
I have skills with python, but I like to create games in roblox studio so I will learn lua from you thanks
i put a script in a part that makes the part disappear and reappear like in a timed jump minigame
while true do
script.Parent.Transparency = 0
script.Parent.CanCollide = true
task.wait(0.35)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
task.wait(0.35)
end
Since I had a bit of trouble learning the for loop, ill explain it here, the second number is how many times the loop will go BUT, the third number tells how many increments it goes it, and the first number is the number it begins at, for example
"for myCount 0.5, 5, 0.5" the first number is the number it begins at, then the third number is how much it goes up each time until it reached the second number, in this case, the loop goes 10 times
Thank you it’s very clear now because I’m not very good at English so yeah xdd
local myWhileCounter = 1
while myWhileCounter >= 5 do
print("Crazy?")
task.wait(0.5)
print("I was crazy once")
task.wait(0.5)
print("They locked me in a room")
task.wait(0.5)
print("A rubber room")
task.wait(0.5)
print("A rubber room with rats")
task.wait(0.5)
print("And rats make me crazy")
task.wait(0.5)
myWhileCounter = myWhileCounter+1
end
7:36 If u said that one second earlier I wouldn't have crashed LOL
Dudeeee tysm i made a gambling game where there everytime you join there is a 4/5 chance to kick you with a bruh sound effect and a 1/5 you stay and it will spawn a bunch ofgreen bricks (money) on the spawnpoint with register sounds for like 10 seconds and then kicks you saying something like “you won” i used your vids in combination with google searches and dev forum
I’ve started kinda skipping through this series because I already know most of the basic computer science, I’m just wondering when he’ll get into user input / player interaction. Because most scripts aren’t very useful if there’s no way for a player to interact with/trigger them
bro really? computer science?
@@0n0rchy i think he means like the basic programming concepts like if statements, loops, variables, etc. :)
If anyone was wondering heres what I've learned after watching the video-
Making and infinitely color changing cube.
local Cube = script.Parent
wait(5)
while true do
for cubeColor = 1, 1, 1 do
Cube.BrickColor = BrickColor.new("Really red")
task.wait(0.5)
Cube.BrickColor = BrickColor.new("Neon orange")
task.wait(0.5)
Cube.BrickColor = BrickColor.new("New Yeller")
task.wait(0.5)
Cube.BrickColor = BrickColor.new("Lime green")
task.wait(0.5)
Cube.BrickColor = BrickColor.new("Bright blue")
task.wait(0.5)
Cube.BrickColor = BrickColor.new("Royal purple")
task.wait(0.5)
end
end
Why does dawg explain it so well
FIRST COMMENR AND UR VIDEOS R AMAZING KEEP POSTING DUDE!
no one cares if you're "first"
protect this guy at all costs
how do you apply this when you get to real scripting? and not just showing up on the output?
That's the neat part, you don't.
@@pryt0n180 You do, but later
You do, but later.
yooo realy cool and realy easy to understand
Also for the while true do you can just put a task.wait(any number that isnt too low here) before your script to prevent it from crashing if you want to make an indefinite loop for some reason but it will still crash eventually if your script is like an instance.new(“part”) and wont destroy any old parts
Will you continue the advance scripting series?
Yes
@@BrawlDevRBLX Ty, I am at lost of a clear direction now that I finished all your advanced tutorials.
@@Yaboy8r1 He will continue the advanced tutorials once he finish these beginner videos
one of the best scripting tutorials out there, thanks
just a question but what does print do in games? Sorry if this question was already asked or just straight up stupid :)
In Lua programming, print is a built-in function that is used to output data to the console or standard output. It allows developers to display values, messages, or other types of information during the execution of a program.
Your amazing at teaching
Before starting the tutorial i only known how to print, but now i am a true proffesional, Thanks!
I made a script that makes the baseplate smoothly blink from transparent to non transparent like this:
local baseplate = game.Workspace.Baseplate
for MyCounter = 1, 10, 1 do
for Counter = 1, 10, 1 do
baseplate.Transparency = baseplate.Transparency + 0.1
task.wait(0.1)
end
for Counter2 = 1, 10, 1 do
baseplate.Transparency = baseplate.Transparency - 0.1
task.wait(0.1)
end
end
you can try it out yourself if you want :D
is there any about I,V tutors? if not i cant wait to see it
with what i learned i did this countdown (also i did the loop mechanic so is changable ez)
for countdown = 3, 3, 3 do
print("3")
wait(1)
print("2")
wait(1)
print("1")
wait(1)
do
print("go")
end
end
(I didnt include while since i cant think of a scenario with it)
Awesome tutorial, heres what I did with it:
local colorChange = game.Workspace.Part
for wowAnotherColor = 1, 355, 1 do
colorChange.BrickColor = BrickColor.random()
task.wait(.7)
for wowAnotherColor2= 1, 1, 1 do
colorChange.Transparency = math.random()
task.wait(.8)
end
end
local baseplate = game.Workspace.Baseplate
for myLoop = 1, 10, 1 do
baseplate.BrickColor = BrickColor.new("Wheat")
task.wait(0.5)
baseplate.BrickColor = BrickColor.new("Teal")
task.wait(0.5)
baseplate.BrickColor = BrickColor.new("Lime green")
task.wait(0.5)
baseplate.BrickColor = BrickColor.new("Navy blue")
task.wait(0.5)
baseplate.BrickColor = BrickColor.new("Toothpaste")
end
6:48 when i did this, i wanted to test it and i didnt listen to the warning, but when i realized the number cant change my roblox studio crashed becuase it made infinite loop
woopsies
I went kinda crazy with this one... Its a part that will change color in a rainbow order and within each color change, it changes the material 9 times within 3 materials and the colour in rainbow order happens 60 times I think it changes a total of 540 times if my math is right... sooo let me just show it 😄
local part = game.Workspace.Part
for myCounter = 1, 10, 1 do
part.BrickColor = BrickColor.new("Really red")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
part.BrickColor = BrickColor.new("Neon orange")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
part.BrickColor = BrickColor.new("New Yeller")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
part.BrickColor = BrickColor.new("Lime green")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
part.BrickColor = BrickColor.new("Deep blue")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
part.BrickColor = BrickColor.new("Royal purple")
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
end
this part repeats a lot so you could make it a function to shorten your script
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
Ex:
local part = game.Workspace.Part
local function myFunction()
task.wait(1)
for myCounter2 = 1, 3, 1 do
part.Material = Enum.Material.Neon
task.wait(1)
part.Material = Enum.Material.Wood
task.wait(1)
part.Material = Enum.Material.CrackedLava
task.wait(1)
end
end
for myCounter = 1, 10, 1 do
part.BrickColor = BrickColor.new("Really red")
myFunction()
part.BrickColor = BrickColor.new("Neon orange")
myFunction()
part.BrickColor = BrickColor.new("New Yeller")
myFunction()
part.BrickColor = BrickColor.new("Lime green")
myFunction()
part.BrickColor = BrickColor.new("Deep blue")
myFunction()
part.BrickColor = BrickColor.new("Royal purple")
myFunction()
end
how do you do this I don’t remember anything from the past episodes
How would you make a loop that continues until a variable is true of false for example
BrawlDev the teacher we never asked for but need this whole time you have earned a sub and here's my learning objective.
local sphere = game.Workspace.RGB
for myCounter = 1, 10, 1 do
sphere.BrickColor = BrickColor.new("Really red")
print("woah im red")
wait(2)
sphere.BrickColor = BrickColor.new("Really blue")
print("woah now im blue")
wait(2)
sphere.BrickColor = BrickColor.new("Lime green")
print("wow grass")
wait(2)
sphere.Material = "LeafyGrass"
print("YAY IM GRASS NOW")
wait(2)
sphere.Material = "Plastic"
sphere.BrickColor = BrickColor.new("Pink")
print("IM A PREPPY PRINCESS NOW")
end
this could help me in making a day night cycle thank you🙂
this is the hardest one yet but living through it i dont understand it fully
while whileloop
Random question.
If I re-uploaded your channel profile picture to Roblox under my account, will you file a DMCA takedown?
I have question, what is the use of task?
When I say wait(insert number here) it works?
local rizz = game.Workspace.rizz
local fp = game.Workspace.FunctionPart
for change = 1, 2, 1 do
fp.BrickColor = BrickColor.Random()
task.wait(1)
for secondChange = 1, 12, 1 do
rizz.BrickColor = BrickColor.Random()
task.wait(1)
print("Working!")
task.wait(1)
end
end
a script that just changes a part and loops
local msg = game.Workspace.Part
local r = game.Workspace.Part
local e = game.Workspace.Part
local s = game.Workspace.Part
local d = game.Workspace.Part
local n = game.Workspace.Part
msg.Material = "Grass"
wait(3)
r.Material = "Metal"
wait(2)
e.Material = "Mud"
wait(2)
s.Material = "Leather"
wait(2)
d.Material = "Snow"
wait(2)
n.Material = "Neon"
wait(1)
for mc = 10, 10 , 10 do
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
print("y")
end
local myh = 1
while myh
for Clant = 1, 1000, 1 do
print('you completed lesson goal for episode 11; this will repeat every second')
task.wait(1)
print("thsi is used to prevent the out from using ###(x#) format")
task.wait(1)
end
here is my code:
local baseplate = game.Workspace.Baseplate
task.wait(3)
for myCounter1 = 1, 9999999999999, 1 do
baseplate.BrickColor = BrickColor.new("Really red")
task.wait(0.1)
baseplate.BrickColor = BrickColor.new("Toothpaste")
task.wait(0.1)
baseplate.BrickColor = BrickColor.new("Lime green")
task.wait(0.1)
baseplate.BrickColor = BrickColor.new("New Yeller")
task.wait(0.1)
end
W vid, learned a lot today. Heres what I made:
local baseplate = game.Workspace.Baseplate
for myCounter = 1, 10, 1 do
baseplate.BrickColor = BrickColor.new("Lime green")
baseplate.Transparency = 0.8
task.wait(1)
baseplate.BrickColor = BrickColor.new("Toothpaste")
baseplate.Transparency = 0
task.wait(1)
for myCounter2 = 1, 3, 1 do
baseplate.Material = "Pebble"
task.wait(1)
baseplate.Material = "Limestone"
end
end
What if i want to use 2 infinite loops at the same time? Will i need to create 2 different scripts?
I used loops, functions and if statement to change the objects transparencty. First I changed it with for loops then with while loops. Here is the script if you want to test and check it out:
local testObject = game.Workspace.TestObject
local test = 0
local test2 = 0
local function changeTransparency(value)
testObject.Transparency = testObject.Transparency + value
end
for i = 1, 10, 1 do
changeTransparency(0.1)
wait(0.1)
if i == 10 then
print("Object is transparent, changing back")
wait(3)
for i2 = 1, 10, 1 do
changeTransparency(-0.1)
wait(0.1)
end
end
end
print("Your object is now visible, proceeding to do the same with while loop")
wait(3)
while test
have you gained 500 subscribers in one day? yesterday I feel like you were at 9.6k!
How many videos will be in this playlist?
18
not sure if i did enough but i should definitely practice this anyways:
for myCounter = 1, 3, 1 do
print("For every time this statement is stated, another statement is stated 5 times")
for myCounter2 = 1, 5, 1 do
print("The statement above is correct")
end
end
local auraLevel = 1000
while auraLevel 9000 then
print("HIS POWER LEVEL IS OVER 9000")
end
end
I love crashing python idle shell using wire loops ( while True:
print(“hi”)
My homework makes a part slow fade away, becoming intangible when it is invisible:
local part = game.Workspace.Part
while part.Transparency 1 then
part.CanCollide = false
end
end
can anyone explain to me a bit more on what the 3rd number does? 4:19
3rd num +/- 1st num so, completes a loop and it plus 1 till it reaches 5, or at 9:55 3rd num is -1 so it -1 from 5 till it reaches 1. Hope it makes sense
Yippee, we are back to messing with the in-game object and not just the output! :D (output was fun too, but I was getting tired of it)
My LO:
local lava = game.Workspace.CrackedLavaPart
local someVariable = 1
local marble = game.Workspace.MarblePart
local function animateLava()
while someVariable
8:04 I already did this I guess I predicted the future lol
7:36 POV: me pressing play right before that
I am loving these episodes, they are so easy to understand. Here are my scripts btw, and what i did was i made multiple different items in my world to keep changing colors infinitely. I made them the same colors though, so they were aligned in the same pattern.
local plate = game.Workspace.Baseplate
while 1 == 1 do
plate.BrickColor = BrickColor.new("Lapis")
wait (0.2)
plate.BrickColor = BrickColor.new("Toothpaste")
wait (0.2)
plate.BrickColor = BrickColor.new("Lime green")
wait (0.2)
plate.BrickColor = BrickColor.new("Deep orange")
wait (0.2)
plate.BrickColor = BrickColor.new("Really red")
wait (0.2)
end
--------------
local part = game.Workspace.ThePart
while 1 == 1 do
part.BrickColor = BrickColor.new("Lapis")
wait (0.2)
part.BrickColor = BrickColor.new("Toothpaste")
wait (0.2)
part.BrickColor = BrickColor.new("Lime green")
wait (0.2)
part.BrickColor = BrickColor.new("Deep orange")
wait (0.2)
part.BrickColor = BrickColor.new("Really red")
wait (0.2)
end
-------------
local spawnpoint = game.Workspace.SpawnLocation
while 1 == 1 do
spawnpoint.BrickColor = BrickColor.new("Lapis")
wait (0.2)
spawnpoint.BrickColor = BrickColor.new("Toothpaste")
wait (0.2)
spawnpoint.BrickColor = BrickColor.new("Lime green")
wait (0.2)
spawnpoint.BrickColor = BrickColor.new("Deep orange")
wait (0.2)
spawnpoint.BrickColor = BrickColor.new("Really red")
wait (0.2)
end
local baseplate = game.Workspace.Baseplate
if 2 + 2 == 4 and 3 + 1 == 4 then
print("working")
for myLoop = 1, 10, 1 do
baseplate.Transparency = 0.1
task.wait(.5)
baseplate.Transparency = 0.5
task.wait(.5)
baseplate.Transparency = 1
task.wait(1)
end
else print("error")
end
Got back to this tutorial after a bit, here's what I wrote:
for myCounter = 1, 5, 1 do
print("A")
for myCounter2 = 1, 5, 1 do
print("B")
end
end
local myWhileCounter = 1
while myWhileCounter
7:30, yes I noticed that... about 30 seconds ago.
local red = game.Workspace.policeRed
local blue = game.Workspace.policeBlue
local function alternatingLights()
red.Transparency = 0.8
if red.Transparency >= 0.8 then
blue.Transparency = 0
blue.Material = "Neon"
end
wait(0.5)
if red.Transparency >= 0.8 then
red.Transparency = 0
red.Material = "Neon"
blue.Material = "Plastic"
blue.Transparency = 0.8
end
wait(0.5)
if blue.Transparency >= 0.8 then
red.Transparency = 0.8
end
end
for lightChange = 1, 10000000, 1 do
alternatingLights()
end
this code is used to make two blocks one red and one blue switch between on and off to simulate a police siren effect love ur videos man
at the start i roght:
while true do
print("yup")
end
wicht then crashes roblox studios and to fix that you have to put a wait()
these numbers r hurting my head WAAAAAAAAAAAAAAAAAAAAAAAAAAAA
sniff.... i will soldier through......
im going outside and lighting myself on fire
if 3 + 3
changed the material
local baseplate = game.Workspace.Baseplate
for mC = 1, 100,1 do
baseplate.Material = "Limestone"
task.wait(1)
baseplate.Material = "Marble"
task.wait(1)
baseplate.Material = "Plastic"
task.wait(1)
end
Brawldev the waiting function doesnt need the "task." Since it still works
Could you maybe do a video on particles and effects? Stuff like auras, beams, etc.
isn't wait(1) the same thing as task.wait(1)
expanded a bit on the script in the video, just made a function with a while loop that goes from 1 to 5, changing the color of the baseplate to a random color every .2 seconds, then sets the whilecounter back to 1. then i put this function in between each of our previously stated for loop, making it a function nested loop? idk but its fun.
local baseplate = game.Workspace.Baseplate
local whileCounter = 1
local function RandomFast()
while whileCounter < 5 do
baseplate.BrickColor = BrickColor.random()
task.wait(0.2)
whileCounter = whileCounter + 1
end
whileCounter = 1
end
for myCounter = 1, 10, 1 do
baseplate.BrickColor = BrickColor.new("Toothpaste")
task.wait(3)
RandomFast()
baseplate.BrickColor = BrickColor.new("Lime green")
task.wait(3)
RandomFast()
baseplate.BrickColor = BrickColor.new("Gold")
task.wait(3)
RandomFast()
end
Ah, loops my nemesis.