No video

Beginner's Roblox Scripting Tutorial #12 - While and Repeat Loops (Beginner to Pro 2019)

  Рет қаралды 233,030

TheDevKing

TheDevKing

Күн бұрын

Beginner's Roblox Scripting Tutorial #12 - While and Repeat Loops (Beginner to Pro 2019)
Hey guys, I'm back and in todays video I am going to be showing you how while loops work and how repeat loops work. Its not too hard but it may be a bit confusing so like always if you ever have any questions about a roblox scripting tutorial of mine be sure to leave it down in the comments below. Anyways I hope you guys enjoy and I will see you in the next one. Peace!
Link to Beginner's Tutorial Series:
• Beginner's Roblox Scri...
-- Follow me on twitter! (my name is tapwater because thats my main channel): / realtapwater
- Join my Discord Server to learn and meet other developers!-
/ discord
--What is this series about and who is it for?
So this series is meant for people who really want to learn exactly how to script, if that is you then I promise by the time you watch this whole series you will know exactly how to script on roblox. Anyways be sure to subscribe to see whenever I release a new tutorial and I will see you guys in the next one. Peace!

Пікірлер: 707
@TheDevKing
@TheDevKing 5 жыл бұрын
Hey guys! Be sure to join the discord server if you have any questions or if you would like to meet me! discord.gg/FKcSyRh
@kaibrouchiha2490
@kaibrouchiha2490 4 жыл бұрын
hotdogs again hmmmmmm :/
@ibeatricebags
@ibeatricebags 3 жыл бұрын
Yessir
@WeeklyShitpost
@WeeklyShitpost 3 жыл бұрын
I'm Banned Maybe or The Link is Expired Revoke My Ban if You Can : Rigby#9052
@Ian-ve7dw
@Ian-ve7dw 3 жыл бұрын
its not working
@XULSS
@XULSS 3 жыл бұрын
@@Ian-ve7dw discord.gg/rodevs
@nathanieluk9818
@nathanieluk9818 4 жыл бұрын
this guys obsession with hotdogs is beginning to worry me
@shinchanthebest
@shinchanthebest 4 жыл бұрын
me too
@dumbgamer4240
@dumbgamer4240 4 жыл бұрын
Hotdogs are just good.
@MarioMario-yb3iz
@MarioMario-yb3iz 4 жыл бұрын
@@dumbgamer4240 no u
@Fidumo
@Fidumo 4 жыл бұрын
@Pizza rolls for days "concern" = concern _me_
@paravalent7974
@paravalent7974 4 жыл бұрын
beginning?
@thegood_soup
@thegood_soup 18 күн бұрын
i struggled a bit but i rewatched some of these and now am able to make a gate that you cant go through normally, but when you touch a key, it changes apparence and lets you walk through it. i wanted to say these are some of the best scripting tutorials out there, even if they are 5 years old.
@OddishSupremacy
@OddishSupremacy 4 жыл бұрын
oh geez i took a break from watching these and came back and forgot that he has an obsession with hotdogs-
@WhiteChocolateSyrup
@WhiteChocolateSyrup 4 жыл бұрын
lmaoooo
@Exquic
@Exquic 4 жыл бұрын
The glizzy king
@awesomeedison1614
@awesomeedison1614 4 жыл бұрын
wats with him and hotdogs
@OddishSupremacy
@OddishSupremacy 4 жыл бұрын
@@awesomeedison1614 idk bro.... Idk.... Prob some kinda child trama
@sai63836
@sai63836 3 жыл бұрын
@@OddishSupremacy I think hotdogs is code for drugs... *local hotdogs = crystal meth* *If hotdogs == crystal meth = true then* *print "YO THESE HOTDOGS DA SHIT*
@yellowpant
@yellowpant 3 жыл бұрын
For anyone that's confused on the first part where the script says hotdogs = hotdogs + 1, basically what its saying is to add 1 hotdog on the first line until it hits 5
@kingbob6174
@kingbob6174 2 жыл бұрын
thx
@danzen5119
@danzen5119 2 жыл бұрын
remember, local hotdogs = hotdogs + 1 and hotdogs = hotdogs + 1 are different output.
@stuntfax9004
@stuntfax9004 2 жыл бұрын
@Yellow Pant I FLIPPING LOVE U DUDE
@xwalfie
@xwalfie Жыл бұрын
hotdogs += 1
@user-mg6zp1zt5j
@user-mg6zp1zt5j Жыл бұрын
Does anyone know if Hotdogs++ works in this programming language? I have an extensive background in programming but I am JUST learning LUA and I am not sure which syntax will work and won't work (basically C++, Java, & Python since the others I know are outdated by now.) Thanks all.
@spithonker944
@spithonker944 4 жыл бұрын
"It will crash my game" Me: Wot I just ran it My game: Ight Imma crash
@qrisquinn
@qrisquinn 4 жыл бұрын
Wait a minute, my game did not crash, like no lag even, I guess I have a good computer.
@kontanaro3979
@kontanaro3979 4 жыл бұрын
if u want game dont crash just make wait and set time how much u want to wait :P edit: im just watching this tutorial and i see he make wait ;-; and he make less than 5 so it didn't crashed
@synx2963
@synx2963 4 жыл бұрын
It almost crashed, and it ran 9932 times xd
@dylan5576
@dylan5576 4 жыл бұрын
i purposely set the script to run it 10000 times, dont.
@MidnightStorm4990
@MidnightStorm4990 3 жыл бұрын
@@qrisquinn Maybe you did it wrong .3.
@randomshow9366
@randomshow9366 3 жыл бұрын
"I'm so pissed at my dog barking!!!" *A fEw mOmenTs laTeR "let's make a variable, we'll call it local HOTDOG" Me: OoooOookay Buddy.
@ldn_future6587
@ldn_future6587 3 жыл бұрын
hahaha
@spiucrus5033
@spiucrus5033 3 жыл бұрын
@@ldn_future6587 local hotdog made by yours truly. the meat mincer.
@ldn_future6587
@ldn_future6587 3 жыл бұрын
@@spiucrus5033 haha
@Zenith_Nulls
@Zenith_Nulls 3 жыл бұрын
yoo💀💀
@attackerstoasdfa
@attackerstoasdfa 3 жыл бұрын
😏😏😏
@brickboyfilms4381
@brickboyfilms4381 4 жыл бұрын
I'm learning so much from these tutorials. Off of learning repeat loops I was able to create a basic blinking light :local light = game.Workspace.light.PointLight local finish = 1 repeat light.Enabled = true wait(2) light.Enabled = false finish = finish + 1 wait(2) print(finish) until finish == 20
@jxshyyy17
@jxshyyy17 4 жыл бұрын
nice!
@abdulrehman-px6tw
@abdulrehman-px6tw 4 жыл бұрын
nice work :)
@brickboyfilms4381
@brickboyfilms4381 4 жыл бұрын
@@abdulrehman-px6tw Thanks :D I've learned a lot more now.
@shinchanthebest
@shinchanthebest 4 жыл бұрын
dude i can tell you are not taking this as a hobby but rather a passion which is naturally created and everyone has one which they need to find(at least i think this way), hope your dreams come true!
@MalPlayss
@MalPlayss 4 жыл бұрын
shinchan the best aww
@fain6809
@fain6809 3 жыл бұрын
just for anyone starting off I recommend you get into the practice of naming your variables relating to the what they actually mean so if you have a variable that just defines the location of a part then name it the name of the part
@Visschi
@Visschi 2 жыл бұрын
@Ok lool
@nineveh17
@nineveh17 2 жыл бұрын
@Ok Lol
@Earth-bx3yy
@Earth-bx3yy Жыл бұрын
@kero7744 Lol
@unknownedleaf
@unknownedleaf 7 ай бұрын
nah im naming everything hotdog
@frankmkk2191
@frankmkk2191 4 жыл бұрын
TheDevKing: “print.. HOTDOGS” Ty btw 😂
@akafriend-9264
@akafriend-9264 2 жыл бұрын
To get a better understanding of while and repeat While is loops are loops that are active when the condition is at that point. Think of it as a if statement Repeat loops are loops that are ended when a condition has happened
@Crystal-pv8ix
@Crystal-pv8ix 5 жыл бұрын
Are you going to continue to make videos? They're really helpful! Thanks a lot, hope u post more!
@TheDevKing
@TheDevKing 5 жыл бұрын
Yes! I am posting today
@equistic6630
@equistic6630 3 жыл бұрын
@@TheDevKing 2 years ago, you have come a very long way, thanks for making these tutorials. I have been watching for nearly 2 years now and I support you. I have recently been crushed by studying and homework and just coming back. You make the most simple tutorials and I support that
@blueorcah2779
@blueorcah2779 3 жыл бұрын
@@equistic6630 ya bro, homework makes you forget everything in programming.
@noobsarebetterthanu5820
@noobsarebetterthanu5820 2 жыл бұрын
@@blueorcah2779 Lol it really does.
@kontanaro3979
@kontanaro3979 4 жыл бұрын
i watched other scripting tutorial but it's like noob scripting and i seen while true do and now im watching u and u have good tutorials :D
@semi-automaticdooropened9007
@semi-automaticdooropened9007 4 жыл бұрын
literally everyone here: makes cool scripts Me: makes 100 lines long useless scripts that rarely work
@certifiedhoodclassic638
@certifiedhoodclassic638 4 жыл бұрын
SAME
@hellotherechild8086
@hellotherechild8086 4 жыл бұрын
To shorten it you should use locals tbh. If you're already using it the idk. I'm new to it.
@Uniyou0459
@Uniyou0459 4 жыл бұрын
I cant even make a 5 line script so you good hawtdog. Also did you get any better?
@kaibrouchiha2490
@kaibrouchiha2490 4 жыл бұрын
but I make 15 lines of code that rarely works :/ wait nvm that's better than urs
@burninghand1946
@burninghand1946 4 жыл бұрын
Can Relate
@katkant
@katkant 2 жыл бұрын
Notes: While loops repeat the code forever until its false. While [something to check for] do [code] End The code will repeat forever until the thing it checks for is false If the while loop goes on forever infinitely fast (without waiting in any part of the code) then the game will crash because infinate things are happening at once infinite times. To avoid this, you can put in a wait function While [something that is always true] do wait() [code] End (For something that is always true, you can just put true, or something like 3 == 3) So what will happen, is the code will repeat forever, but wait every time it runs. If you write wait(2) it will wait two second, and you can write any number you want, even numbers smaller than one, but if you keep it empty then it will be the smallest number the program can possibly run. So it will be extremely fast, without crashing Repeat loops; Repeat loops will run forever until something happens. Example: Repeat [code] Until 2 == “lol” So the loop will run forever, but stop when lol is 2
@mladenk6069
@mladenk6069 2 жыл бұрын
tysm this was so helpful
@jasonfessler4763
@jasonfessler4763 Жыл бұрын
mans wrote a paragraph
@velocitydam5090
@velocitydam5090 Жыл бұрын
tysm!
@FireCobra
@FireCobra 9 ай бұрын
Im late but you are a savior
@dudududududi
@dudududududi 4 жыл бұрын
I just found out your main channel is tapwater
@skyface5899
@skyface5899 4 жыл бұрын
TheDevKing: *Puts the condition of the while command to "true"* The computer: What's being set to true?
@altasura3235
@altasura3235 3 жыл бұрын
Attempt to index nil with "true"
@jasonfessler4763
@jasonfessler4763 Жыл бұрын
world war 3 is true
@ancientBockz
@ancientBockz Ай бұрын
WHY DID YOU TELL ME MY GAME WAS GONNA CRASH AFTER I RAN IT!!!! But fr this man has the best tutorials ever!!!
@smonkey9537
@smonkey9537 3 жыл бұрын
0:38 my heart sank and I thought he was going to say 'my dog died'
@gabpoo973
@gabpoo973 3 жыл бұрын
lol same
@LJ07EBP
@LJ07EBP 3 жыл бұрын
Same man.
@audigamer8261
@audigamer8261 3 жыл бұрын
Same
@mrboi3734
@mrboi3734 3 жыл бұрын
SAME
@rinaldskalvis5071
@rinaldskalvis5071 5 жыл бұрын
Make more video's! Btw, you have earned my subscribe!
@TheDevKing
@TheDevKing 5 жыл бұрын
Thanks bro :) I will!
@alfredorourke8715
@alfredorourke8715 4 жыл бұрын
ok i love the way u explain loop functions in this bc i have created 3 games in unity using c# and couldn't understand those functions until this video. Keep up the good work m8 your tutorials is a good place for anyone to start who wants to learn lua.
@roblox-universes
@roblox-universes 9 ай бұрын
you mean you created 3 games with roblox lua?
@monke8823
@monke8823 8 ай бұрын
@@roblox-universes what
@savitaandhale-ci7ui
@savitaandhale-ci7ui 8 ай бұрын
@@roblox-universes no he created 3 games in unity using c#. He did not used to understand the while loops in c#
@Jixfyi466
@Jixfyi466 2 ай бұрын
@@savitaandhale-ci7uiaka C sharp
@kaibrouchiha2490
@kaibrouchiha2490 4 жыл бұрын
dev king - this was my 5th time recording this video - dev kings dog - no this was his 15th time HAHAHAHAHAHHAHA
@zeptopiagaming7428
@zeptopiagaming7428 Жыл бұрын
I think repeat loops could be used to make mobile buttons for guns Like repeat Until button pressed = false
@dogeoleon
@dogeoleon 9 ай бұрын
for anyone wondering about the For loops, this is kinda how they work: for count = 10, 0, -1 do print(count) wait(1) end This is a countdown timer where the For loop will run until the countdown reaches 0. 10 is the starting number (first value), 0 is the number we will stop at (second value) and -1 is the rate at which we will tick the count down by (third value). Print it and use a wait function set to 1. Boom! I can't really explain For loops very well but this is a basic run down of what its like! =)
@chickenoodle3397
@chickenoodle3397 3 жыл бұрын
OMG this video helped so much i was messing around and i was trying to loop a brick and i did stuff and i kept watching ur series and i tried this on my script
@jasonfessler4763
@jasonfessler4763 Жыл бұрын
average devking fan be like:
@UltraCodedZero
@UltraCodedZero 16 күн бұрын
@@jasonfessler4763 but he is good at teaching fr
@mendusss
@mendusss 2 жыл бұрын
I had no experience at all with scripting at the begining of this series. Thx for the vids.
@sand8673
@sand8673 4 жыл бұрын
while true do print("TheDevKing is cool") wait() end
@THE-VIRTUOUS-GUILD
@THE-VIRTUOUS-GUILD 3 жыл бұрын
lol
@thevoid5181
@thevoid5181 3 жыл бұрын
i understand the reapet loop you just type in repeat then you type what you want it to repeat and when youre done you just type in what thats gona stop it on the right side of until!
@Moon_Slayer0
@Moon_Slayer0 20 күн бұрын
For anyone confused, repeat loops can be considered as the opposite of while do's. Repeat loops run a certain code "until" keyword "until" a certain condition is met. And in this case the condition will never be met resulting in an infinite loop of printing the variable.
@user-mg6zp1zt5j
@user-mg6zp1zt5j Жыл бұрын
Hello, I hope you wont mind a little feedback on your tutorials that may help you to grow as in instructor. I have been watching this playlist up until now and I have noticed a few things. First, you tend to speak very fast and erratic. Practicing a more casual pace, may help you reduce not only speaking errors, but with typing and coding errors as well. In addition, a more planned out script or outline may help you to use less "filler words" like GUYS, UM, WHATEVER, etc. The most important thing about an educational video isn't how much you can cram into a single 3 minutes, but how much the student can absorb about the subject. Second, while making a continuous video is admirable, don't be hesitant to cut out the errors. Students seeing these are most likely making an IMPRINT in their mind about these lessons. A faux pas can imprint just as easily for a first time student, and that can make all their future uses difficult. It is ok to mention the error in the reshoot, like "You don't need parentheses after this function call in this case and that is a common mistake, so be sure you note that," but to show 3 wrong attempts and 1 working will always lead to a few students remembering incorrectly which was the proper procedure. Lastly, your students will benefit from a few extra seconds of explanation in all things. Saying "just do this and it's not important why for now" is a difficult process for our minds to handle in most cases. Teaching is about giving and receiving information, and for that, a certain level of trust is ALWAYS under a natural level of scrutiny. Once a student's mind is in a defensive position, they may not be as receptive. It is better to give a brief explanation followed by reassurance that that will be covered more in depth later on in the course and it is ok if the students don't fully understand as long as they know the basic info. For instance, here, you mention the 3 types of loops, but you never specified the basic programming principles in why 3 loops exist, and how they are different. The main important point would be to say that a REPEAT loop, will ALWAYS run once, but FOR and WHILE loops are conditional. As a side note, I would also suggest you pre-plan the names of your variables within the lecture, and maybe even take some time to plan out a real world use for each lesson. One can only hear HOTDOG so many times before it becomes confusing. If you just like the word HOTDOG as a variable try to still work that into a situation like a game about a hotdog stand, so HOTDOGS is the number you have left in the cart, and your IF statements and functions can be local function RESTOCK(Item, qty) or local function COUPON(Item, discount, DoP), where you can pass in the item, and a quantity to fill the inventory, or you can get back a reduced price for an item by passing in the item, the discount, and a switch for Dollars off, or Percent off respectively. I mean all of this only as constructive criticism for a young educator who shows great potential. Keep up the good work and never stop learning. Have a great day.
@epicfs7846
@epicfs7846 Жыл бұрын
this is 4 years old-
@exanimus211
@exanimus211 10 ай бұрын
bro posted an entire yapping session
@Gotenn3
@Gotenn3 4 жыл бұрын
What i don’t get is what the printing actually do, like what is it doing in the game, how is it helping u etc..
@Sarvesh_C
@Sarvesh_C 4 жыл бұрын
i am confused about that too like what are we gonna do with the output
@Genzokyou
@Genzokyou 4 жыл бұрын
@@Sarvesh_C It is mostly to check if script is running alright, like; When a script doesn't work, it don't run at all, it stop at certain line, and when it work, it doesn't show in output if you don't have a print command to show it is working
@seathesauce
@seathesauce 3 жыл бұрын
Well you can test if a script does work An example: game.Workspace.Part.Touched: Connect() game.workspace.hotdog.Anchored = true print("script successfully completed") end
@MonkeyCat__
@MonkeyCat__ 3 жыл бұрын
@@seathesauce u and @NK said it before me :v
@SealSal
@SealSal 5 жыл бұрын
Ohhh now I know why Var1+1 wont work its because I need Var1 = Var1 + 1
@ufoulroo2035
@ufoulroo2035 5 жыл бұрын
Yeah👍
@linear2822
@linear2822 4 жыл бұрын
Yea because the script doesn’t know what value var1 holds
@MarioMario-yb3iz
@MarioMario-yb3iz 4 жыл бұрын
@@linear2822 k
@sanicishere7295
@sanicishere7295 4 жыл бұрын
Notice you can also do var1+=1 don't know how it worked =P
@sanicishere7295
@sanicishere7295 3 жыл бұрын
you could increment it by one with Var1 += 1. It does work with Java, and it worked last time I tested it in Lua, so idk
@brutalreal569
@brutalreal569 2 жыл бұрын
im writing down everything on a paper so then i remeber thank you devking you are awsome 😀
@marmaje6953
@marmaje6953 Жыл бұрын
Ok now it finally works: While true do Script.parent.Sound.Playing = true task.wait(2) end Now i can play the sound effect with a bit of a gap like i wanted.
@chill_bird
@chill_bird Жыл бұрын
"My dog wouldn't shut up" had me dying 😂😂😂
@QUBIQUBED
@QUBIQUBED 2 жыл бұрын
I made my own board that displays how old the server is with just this video because it was so well explained! No need for KZfaq tutorials anymore :D
@elektro860
@elektro860 4 жыл бұрын
its good if you want do something like cant die until wait(3) so like this repeat wait() until wait(3)
@pixel8596
@pixel8596 4 жыл бұрын
Thanks for another good tutorial :)
@happygeeked
@happygeeked Жыл бұрын
i thought you was finna say that yo dog died
@soollz4072
@soollz4072 7 ай бұрын
local X = 1 -- variable = 1 repeat X = X + 1 -- it adds 1 to the variable value every time it fires until X == 3 -- it will stop at 3 if X == 3 then -- checking if X = 3 print("X equals three") -- if then it will print, like a train that goes from one station to another end
@notprotoy5383
@notprotoy5383 Жыл бұрын
While loops were real fun to use in Python when our school taught us. I remember me and my dumb friends trying to crash our Computer Lab PCs and we failed for not being able to run multiple of them at once. Still a funny memory in my opinion.
@user-do8jq4kd5z
@user-do8jq4kd5z 3 жыл бұрын
2:22 Or, you could do hotdogs += 1. It would still add 1 to the hotdog variable
@frockfor
@frockfor 2 жыл бұрын
wow thank you i never knew that
@Corvus_the_wyvern
@Corvus_the_wyvern 3 жыл бұрын
So I stopped watching vids for tutorials and found out the dev page and lua learning on roblox are great resources and I would suggest them
@mexicanfloppa
@mexicanfloppa Ай бұрын
for anyone whos wondering why this isnt working for you its because lua has changed just a bit instead of putting **do** after hotdogs < 5 put it before hotdogs = hotdogs + 1
@medasgaradauskas5027
@medasgaradauskas5027 Ай бұрын
TYSM
@mexicanfloppa
@mexicanfloppa Ай бұрын
@@medasgaradauskas5027 yw bro :))
@handsomechocolatebar276
@handsomechocolatebar276 5 жыл бұрын
What happened to the series?
@TheDevKing
@TheDevKing 5 жыл бұрын
uploading again today
@50shadesoflamps48
@50shadesoflamps48 5 жыл бұрын
@@TheDevKing hurray lel
@bradleywhais7779
@bradleywhais7779 4 жыл бұрын
you can also do hotdogs += 1 (I know python and there is a lot that is the same.)
@Darksnake87
@Darksnake87 3 жыл бұрын
Every coding language is kind the same
@MonkeyCat__
@MonkeyCat__ 3 жыл бұрын
i learned python to its basicaly the same in alot of things except that the elseif is called elif in python
@Crazyperson720
@Crazyperson720 3 жыл бұрын
It crazy i learned so much just watching your tutorials!
@AuntPopsie
@AuntPopsie Жыл бұрын
When he said he won’t run the code because it will crash his game I ran it before he said that and now my screen is frozen…😢
@theblobhi6228
@theblobhi6228 5 жыл бұрын
for some reason i don't have an output, but your videos taught me so much
@emmettnredblue1857
@emmettnredblue1857 5 жыл бұрын
Go to view and click it at the top and select output
@rioxdeveleopers7125
@rioxdeveleopers7125 3 жыл бұрын
Idk if you still read the comments to this video since it was made in 2018 but thanks this helped out a lot!
@fabrio.8416
@fabrio.8416 4 жыл бұрын
You need to put waits in loops because i didn't and it crashed(not only studio)my computer and i needed to force shutdown.
@snipezcha0s998
@snipezcha0s998 4 жыл бұрын
i made a count down timer with this local timer = 10 repeat print (timer) timer = timer - 1 wait (1) until timer == 0 if timer == 0 then print ("go!") end
@shinchanthebest
@shinchanthebest 4 жыл бұрын
dude i can tell you are not taking this as a hobby but rather a passion which is naturally created and everyone has one which they need to find(at least i think this way), hope your dreams come true!
@parkje1262
@parkje1262 4 жыл бұрын
I guess using Scratch for 3 years and 8 months helped me quite a lot with these tutorials, I basically have to remember the syntax now.
@sandpaperunderthetable6708
@sandpaperunderthetable6708 3 жыл бұрын
Scratch is not very similar to this.
@mikathegaything
@mikathegaything 3 жыл бұрын
@@sandpaperunderthetable6708 scratch haters unite
@sandpaperunderthetable6708
@sandpaperunderthetable6708 3 жыл бұрын
@@mikathegaything i use scratch to create new programming languages or data management stuff
@QUBIQUBED
@QUBIQUBED 2 жыл бұрын
@@mikathegaything scratch is good though, it teaches you the logic of coding
@QUBIQUBED
@QUBIQUBED 2 жыл бұрын
@@sandpaperunderthetable6708 yeah some blocks (like pen blocks) don't have direct lua counterparts but mainly the logic in scratch is the same only the Syntax (like literally every programming language) is different
@lemmysagaert1293
@lemmysagaert1293 3 жыл бұрын
The repeat until loop is easy to use . it indeeds will run the function between there once even if the value is already above the until loop. for example: local t = 1 repeat print('REPEAT LOOP: ', t) t= t+1 until t == 5 in this case it will print 1 2 3 4 and then t reaches 5 and goes on in the script. so instead of the for loop that will look if the statement is true the while loop just goes 1 times true the function and then checks. if the statement (t) is 5 the for loop indeed does the same but stops at the counter of 5 and the repeat untill will stop at 4 that should be explained enough i think Still like your videos mate they are good for beginner script learning in roblox :) :)
@googlejobs934
@googlejobs934 2 жыл бұрын
you could instead use a for loop Ex: for i = 1, 5, 1 do print("repeat loop" .. i) end
@insomnolent5539
@insomnolent5539 2 жыл бұрын
I don't know why I like this so much local num1 = 1 while num1 < 10 do print(num1) wait(.1) num1 = num1 + .1 end print("Finished!")
@prestensu
@prestensu 4 жыл бұрын
thank you for teaching me, i made a part that disappear and appear in roblox :D
@MonkeyCat__
@MonkeyCat__ 3 жыл бұрын
Wow
@MonkeyCat__
@MonkeyCat__ 3 жыл бұрын
Thats so cool
@sanicishere7295
@sanicishere7295 4 жыл бұрын
2:27 Just discovered you can also do hotdogs +=1 to increment it by 1
@unsimplehumain116
@unsimplehumain116 3 жыл бұрын
yes i only thought about that do u know what python is ?
@ikyyntts7807
@ikyyntts7807 3 жыл бұрын
@@unsimplehumain116 literally every programming language has this
@unsimplehumain116
@unsimplehumain116 3 жыл бұрын
@@ikyyntts7807 not cc+ and hdm
@ikyyntts7807
@ikyyntts7807 3 жыл бұрын
@@unsimplehumain116 i believe you mean c++, also c++ does use += as i just tested it. what is hdm??
@unsimplehumain116
@unsimplehumain116 3 жыл бұрын
@@ikyyntts7807 yes i meant c++ ( begginer ) but it doesnt let me +=, >=
@Fearlesscardinal
@Fearlesscardinal 3 ай бұрын
If you want a repeat loop to go for ever then you cando repeat (script) until nil . Nil makes it go forever sense its nothing
@jonknee397
@jonknee397 3 жыл бұрын
Made a 5 minute timer from a bit of scripting knowledge, mixed with the help of your videos Seconds = 60 Minutes = 4 while Minutes
@remmac
@remmac 3 жыл бұрын
oh jeez i actually understood all that
@tertilicon
@tertilicon 2 жыл бұрын
I also tried to make this script it took like 30 mins. Is it good? local minutes = 2 local seconds = 0 while minutes > -1 do wait(1) if minutes == 0 then if seconds > 0 then print(seconds .. " seconds are left.") seconds = seconds - 1 else print("Timer has ended.") minutes = minutes - 1 end elseif minutes > 0 then if minutes == 1 then if seconds == 0 then print(minutes .. " minute and " .. seconds .. " seconds are left.") seconds = 59 minutes = minutes - 1 else print(minutes .. " minute and " .. seconds .. " seconds are left.") seconds = seconds - 1 end else if seconds == 0 then print(minutes .. " minutes and " .. seconds .. " seconds are left.") seconds = 59 minutes = minutes - 1 else print(minutes .. " minutes and " .. seconds .. " seconds are left.") seconds = seconds - 1 end end end end
@goldyplayz5819
@goldyplayz5819 Жыл бұрын
This is my second time watching through and everything makes so much more sense
@Demistro_
@Demistro_ 8 күн бұрын
After learning this I made an blinking light! Code: local light = game.Workspace.Light local function BlinkLight() light.Material = Enum.Material.SmoothPlastic light.Color = Color3.fromRGB(255, 255, 255) light.Anchored = true repeat wait(2) light.Material = Enum.Material.Neon light.Color = Color3.fromRGB(255, 255, 0) wait(2) light.Material = Enum.Material.SmoothPlastic light.Color = Color3.fromRGB(255, 255, 255) until false end BlinkLight()
@biancapascua5150
@biancapascua5150 3 жыл бұрын
u teach better than my math teacher :DD
@BaconIsEgg4
@BaconIsEgg4 10 ай бұрын
This man is gonna solve world hunger with how many hotdogs he just made
@LP_Alex007
@LP_Alex007 Жыл бұрын
This is the first tutorial that really helped me, thank you!
@KirstenRenae97
@KirstenRenae97 2 жыл бұрын
I was trying to make a timer and was stuck on the same error. This fixed it. I spent an hour trying to fix it
@talesofterune873
@talesofterune873 2 жыл бұрын
even while mad you still keep it together. ur the best.
@Vrethrenz
@Vrethrenz 7 ай бұрын
Really wanted to learn repeat loops, i find it very crucial to alot of games
@Qimbro
@Qimbro Жыл бұрын
thanks these are the most easiest-understanding lessons ive ever seen!
@ratmanprisma4452
@ratmanprisma4452 10 ай бұрын
The dog arc continues
@wintry6205
@wintry6205 4 жыл бұрын
I'm struggling really badly on something that should be simple. So instead of testing this on the prints, I tried experiencing it with some blocks to see what it can actually do in the game. Here is the script I wrote: local redblock = game.Workspace.part1 local blueblock = game.Workspace.part2 local function touched() -- When I touch the part1 wait (1) redblock.Anchored=false wait (1) redblock.Transparency=0.7 end redblock.Touched:Connect(touched) while redblock.Transparency==0.7 do -- as soon as the redblock turns into transparency 0.7, this script below should run blueblock.Anchored=false end So my goal here was to make it so that when I touch the part1, it would run the "touched()" function first. As soon as the transparency for the first function goes into 0.7 it should then run my "while" script. But for some reason the while-script doesn't run after the redblock.Transparency=0.7, I'm not getting any errors in my output either. Does anyone know what I'm doing wrong here? This video is a year long, and I doubt anyone will reply, but if there's anyone who could help me please do asap.
@_divisionexpertt_5003
@_divisionexpertt_5003 2 жыл бұрын
So I believe its because you did change the transparency of the red block in the workspace in the while script you are referring to a red block that doesn't have a transparency of 0.7 sorry if this doesn't help
@gdog8170
@gdog8170 Жыл бұрын
you already unanchored it so the while script doesn't do anything because it's already unanchored so nothing changed
@gdog8170
@gdog8170 Жыл бұрын
oh nvm I confused red block and blue block
@gdog8170
@gdog8170 Жыл бұрын
so I asked ChatGPT and it said the following: The issue with this script is that the while loop is blocking the main thread and preventing the Touched event handler from being triggered again. This means that the loop will never exit, and the code inside it will never run. To fix the issue, you need to remove the while loop and instead use a repeat...until loop that checks the Transparency property of the red block after waiting for 0.1 seconds. Here's an updated version of the script: local redBlock = game.Workspace.Redblock local blueBlock = game.Workspace.Blueblock redBlock.Touched:Connect(function() print("redblock touched") wait(4) redBlock.Transparency = 0.7 repeat wait(0.1) until redBlock.Transparency == 0.7 blueBlock.Anchored = false wait(4) redBlock.Transparency = 0.9 end) This code will set the Transparency property of the red block to 0.7 when it is touched, then wait for the Transparency property to be set back to 0.7 (which happens when the player stops touching the block). Once the Transparency property is set back to 0.7, the script will set the Anchored property of the blue block to false, wait for 4 seconds, and then set the Transparency property of the red block to 0.9. **EDITED: ChatGPT wrote the code wrong so I corrected it** here's the correct code: local redBlock = game.Workspace.Redblock local blueBlock = game.Workspace.Blueblock redBlock.Touched:Connect(function() print("redblock touched") wait(4) redBlock.Transparency = 0.7 repeat wait(0.1) blueBlock.Anchored = false wait(4) redBlock.Transparency = 0.9 until redBlock.Transparency == 0.9 end)
@Black_ShadowTBN
@Black_ShadowTBN Жыл бұрын
Hey,I think for what you are trying to do,we dont use a loop :(I tested it it works) local RedBlock = game.Workspace.Part1 local BlueBlock = game.Workspace.Part2 function WhenTouched() BlueBlock.Anchored = false wait(2) end RedBlock.Touched:Connect(WhenTouched) ---script-- if you touch it it will be anchored,it will do this every time
@cat-nl4sv
@cat-nl4sv 2 жыл бұрын
Im trying to get some code to repeat and its not repeating heres the code: while true do t = 47 repeat t = t-1 script.Parent.Position = script.Parent.Position + Vector3.new(-2,0,0) wait(0.5) until t == 0 wait(5) t = 1 repeat t = t-1 script.Parent.Position = script.Parent.Position + Vector3.new(94,0,0) wait(0.5) until t == 0 its to move a brick in the output it just says stack end
@juniorzeddc1888
@juniorzeddc1888 3 жыл бұрын
Very impressed that my computer handled the infinite loop. Lagged for 2 seconds then started playing like normal.
@WillowDevelops
@WillowDevelops 2 жыл бұрын
Same here. And it stopped after printing like a million times and the output says " Script timeout: exhausted allowed execution time" Pretty cool!
@practicalcucumber1395
@practicalcucumber1395 2 жыл бұрын
yeah it stops it after some time
@PossiblePanda
@PossiblePanda Жыл бұрын
For the first part with hotdogs = hotdogs + 1 you can now do hotdogs += 1 and it will do the exact same thing but shorter :)
@kevinduliesco5468
@kevinduliesco5468 3 жыл бұрын
I have subscribed thedevking you earned it and I'm amazed about how the way I understand it quickly because of your way of teaching. :> )
@JolaAdejumo
@JolaAdejumo Ай бұрын
Pls what are the main purpose of loops
@oliverliroman295
@oliverliroman295 3 жыл бұрын
Instructions unclear, hotdogs spawning everywhere.
@simplechannle3045
@simplechannle3045 3 жыл бұрын
This video explained the repeat function good I created my recurring jump scare with this video nice work
@ilmansalt
@ilmansalt 3 жыл бұрын
FYI: you can use "repeat until" to freeze scripts. Example: hotdogs = 1 print("Hi there") repeat until hotdogs == 3 --freezes the script print("i will not print anything until hotdogs is equal to 3")
@googlejobs934
@googlejobs934 2 жыл бұрын
you coudl use a while loop that goes infinitely tho instead of repeat
@nineveh17
@nineveh17 3 жыл бұрын
day #7 of learning to script I'm gonna do this to remind myself to come here everyday(that's not guaranteed)
@AmauryChihuahua
@AmauryChihuahua 9 ай бұрын
quick tip yall, you can use compound assignment operators(find in documentation) to increase a variables value For example --- while hotDogs < 5 do hotDogs += 1 end --- As you see, the code is much more cleaner
@basicnodes7029
@basicnodes7029 2 жыл бұрын
i used scratch A LOT before so im getting theese tutorials *real fast*
@Bababoyiscool
@Bababoyiscool 25 күн бұрын
Lua is like scratch but you type it instead of choosing
@phattan3625
@phattan3625 Ай бұрын
i tried it actually crased my pc
@Moonjapp
@Moonjapp 3 жыл бұрын
Made a script that restarts after it has finished with the loop so it can loop again! Pretty simple but here ya gooo. while true do local Thing = 0 while Thing < 10 do print("Working") wait(1) Thing = Thing +1 print(Thing) end wait(1) print("Restarting") wait(1) print(5) wait(1) print(4) wait(1) print(3) wait(1) print(2) wait(1) print(1) local Thing = 0 end
@ecoa
@ecoa 2 жыл бұрын
at 2:27 instead of doing "hotdogs = hotdogs + 1" you can do "hotdogs += 1"
@leleeora9572
@leleeora9572 2 жыл бұрын
Love you! Also, Just making sure;Functions are something that makes whatever you put in the () work?
@syclasmfn1850
@syclasmfn1850 5 жыл бұрын
why dont you put apostrophe on hot dogs when you typed print(hotdogs)
@EPIC_EDITZ21
@EPIC_EDITZ21 Ай бұрын
Now I understand why he's dog keeps barking. Because he always say hotdog.
@astraphoy1106
@astraphoy1106 3 жыл бұрын
1:54 I pressed run right as you said that lol
@jakie_z3663
@jakie_z3663 4 жыл бұрын
First Script: local light = game.Workspace.Part.PointLight while true do wait() light.Enabled = true wait() light.Enabled = false end
@sanicishere7295
@sanicishere7295 3 жыл бұрын
light had a stroke trying to repeatedly change states and fricking died
@RSISSY_
@RSISSY_ 2 ай бұрын
for i, v in pairs is actually: for index, value in pairs
@Potato_Pizzer
@Potato_Pizzer 2 жыл бұрын
A shortcut now is using hotdogs += 1 or the number you want to add
@mercya.4492
@mercya.4492 2 жыл бұрын
While loops run only WHILE a condition is true, and repeat loops run UNTIL a condition is true.
@Elcat770
@Elcat770 28 күн бұрын
i figured this out the hard way- i fyour going to use reapeat loops use a wait thing becasue your coumputer will explode if you dont
@Zaya095
@Zaya095 2 жыл бұрын
This hotdog obsession needs to be looked at by a doctor lol
@sachinezreed4851
@sachinezreed4851 2 жыл бұрын
Hey I always wanted to make a train system in my game but I know what video is appropriate
@OtakuGamer30
@OtakuGamer30 Жыл бұрын
TheDevKing every second : ummmmmm 😂😂😂
@randomshiba779
@randomshiba779 Жыл бұрын
whats this dudes obsession with hotdogs
@duckyduck1
@duckyduck1 7 ай бұрын
Basically whats going on with while and repeat loops are that: While loops check if somethings true and runs code while this do -- code end Repeat loops check if somethings false and runs code repeat --code until this
@kuliid
@kuliid Жыл бұрын
So in the first part instead of hotdogs = hotdogs + 1, you could do hotdogs += 1, without having to repeat hotdogs twice which is more faster for typing long lines of codes, etc
@user-ch3id4lt2j
@user-ch3id4lt2j Жыл бұрын
make a screenGui in StarterGui then add a TextLabel on it and change the text whatever u want then add a local script and type this on it: local Time = 5 -- the time local StopTime = 0 -- when it stop local minusNumber = 1 -- minus number local TimeLabel = script.Parent.TextLabel function changeTime() TimeLabel.Text = Time end while Time > StopTime do wait(1) Time = Time - minusNumber changeTime() end
A Fan Asked Why His Game is Failing...
30:53
RoBuilder
Рет қаралды 140 М.
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 15 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 47 МЛН
ChatGPT Makes a Scratch Game
10:30
PolyMars++
Рет қаралды 1 МЛН
DON'T Make a Roblox Game Without Watching This First.
27:20
SmartyRBX
Рет қаралды 537 М.
I Scripted Your Funny Roblox Ideas.. (Part 10)
9:13
TheDevKing
Рет қаралды 2,4 МЛН
How pro Roblox developers learnt to script
10:03
AlvinBlox
Рет қаралды 850 М.
I Paid Fiverr Game Developers to Make the Same Game
10:25
BadGameDev
Рет қаралды 676 М.
Making a Game in Lua with No Experience
5:52
Goodgis
Рет қаралды 298 М.
I Scripted Your Funny Roblox Ideas.. (Part 16)
8:02
TheDevKing
Рет қаралды 6 МЛН
I Scripted Your Funny Roblox Ideas.. (Part 13)
6:37
TheDevKing
Рет қаралды 3,3 МЛН
I Made a Fake Warning to Scare Roblox Players
16:31
ByteBlox
Рет қаралды 949 М.