Even though this video was made a year ago it really helped me, I found Functions confusing and this video perfectly explained it in a short amount of time! Your short videos are excellent and honestly are one of the most effective ways to learn Lua!
I like this a ton even though I don't need the video because I already learned how to script along time ago I still see this as a really good scripting tutorial as for people that don't know how to script yet.
thx to you and creator docum i finally know the basic of scripting example: local base = game.workspace.baseplate(Local baseplate = script.parent) local function invisible() base.transperancy = 1 end local function visible() base.transperancy = 0 end while true do wait(5) visible() wait(5) invisible() end edit:thx again
mine is better local touchedPlayers = {} game.Workspace.Part.Touched:Connect(function(hit) local plr = game.Player:GetPlayerFromCharacter(hit.Parent) if plr == nil then return; end if touchedPlayers[plr.Name] == true then return; end plr.Character.Humanoid.Speed = plr.Character.Humanoid.Speed*4.5 touchedPlayers[plr.Name] = true end)
lets say u have a table local mt = {} -- My table -- Now if we wants to make a function to that now we can assign functions to that table function mt:myFunction() end -- or function mt.new() end -- constructor if u know what that means. -- 2 ways to link functions to tables Is this what u asked for?
Why would you want to use a function to print something tho i mean just use the default print function you are provided and you did not even show how to use parameters.
You can choose them. For example: local Hello = 13 if Hello == 13 then print("It is thirteen") else print("It is any number but thirteen") In this scenario, you choose to make Hello be equal to 13. It could be bananas, apples, gold bars, etc.
How do I make the script check for a value constantly like I have a folder in startercharacter scripts and I want a loca script to always be checking for a value that is on inside of that folder
@@dimxx987 no idiot, we should be having server scripts under server script service that handles workspace part manipulation. We shouldn’t get into the habit of putting scripts under parts.
Yo bro i opened roblox stusio and the screen wasnt inside the toolbox thing and i had to resize it inside and whenever i try clicking enter it just selects all Edit:plus if i make a new script the print doesnt show up and when i click the minus button the print is outside
If you are using the function outside the event, Is better for it to have its own definition. For example, you reload a gun not only by pressing 'R', but also by emptying your mag, so two different situations where the function Will be calles.
Printing is used for debugging/testing mainly. Say for example something isn't working in your code, but youre not entirely sure where? Well, thats where printing can come in handy, because itll tell you in the output once it reaches the line with the print in it. So for example, if you have an if statement with some code in it, and its not running, you could put a print at the start of your if statement to check if your script is actually reading that if statement, and if the condition of the statement is true. If for whatever reason, it doesnt print to the output, then boom, you just discovered part of your problem. As for strings, they are also not pointless. A lot of things on Roblox require text(AKA a string). Need to rename something like a part for example? Use a string.
You use print a lot, not for the players, but for you as a dev, It helps checking errors, It helps checking wether the Code stops in some place, It helps to check if the outputs are valid. And Strings are SUPER important, anything you see as text in any place, Is a String, even numbers, as their binary format can't be just simply shown.
for people is finding in Comments: Localed script credit Copy give majdbebo: Scripting youtuber: Script: local message = "i like pizza" function printmessage() print(message) end script.Parent.Touched(printmessage)
suppose ur building a shooting game. you made a gun. the speed of the gun shooting is 2 second. u enter that in a variable and use the variable in many other places of the script.
Stores data in an accesible way. Let's say you have a value object in script.parent.folder1.folder2.module.value, you can store that reference into a variable, and then, you can access that data from your variable.
Variable declaration only exists for that scope and lower levels. There's the global scope, when you create a function, the function Is part of the global scope, all variables you create inside that function are part of the function scope. Not using 'local' forces the variable to be global scope, which Is not always the case, so in short, always use 'local' just to be sure.
@@el_turafor instance to print a variable you could do local variable = “Hello World” local variable2 = “, yes” while true do wait(1) print “(variable)..(variable2)” I think this is lua syntax I use c++ or c# tho This would print Hello World, yes
Full vid: quizgrid.com
⬇️ P̶R̶E̶S̶S̶ T̶R̶A̶N̶S̶L̶A̶T̶E̶ T̶O̶ T̶U̶R̶N̶ O̶N̶ L̶I̶N̶K̶
@AlexExtra-dw2qw You dont look like you have a job ngl
what@@btricks2945
0:00
On some it dont works😢
Even though this video was made a year ago it really helped me, I found Functions confusing and this video perfectly explained it in a short amount of time! Your short videos are excellent and honestly are one of the most effective ways to learn Lua!
O cool!!
bot
It's just define but in Lua
I like this a ton even though I don't need the video because I already learned how to script along time ago I still see this as a really good scripting tutorial as for people that don't know how to script yet.
Thats sweet, I'm a newbie for this but passionate for it.
Thats why i quit scripting ranked too many sweats (math.rad, math.deg, math.clamped, Unreliable events, secret())
Im learning camera shit rn
This is so entertaining 😂 keep it up
sup fedora ✌️
I’m glad I took all those web design and computer programming lessons now
Thanks bro now i understood how to use function
-Big brother that using his Lil bro account
i wonder if the little bro knows that he was using his account for this
Stop the cap
@zeno3447what?
@@Lemonighter its like something that functions an objects child (as far as ik)
This was helpful. Now, I can finally add different music to different parts of my game.
OH MY GOD YOURE RIGHT! TYSM FOR THE IDEA
thx to you and creator docum i finally know the basic of scripting example:
local base = game.workspace.baseplate(Local baseplate = script.parent)
local function invisible()
base.transperancy = 1
end
local function visible()
base.transperancy = 0
end
while true do
wait(5)
visible()
wait(5)
invisible()
end
edit:thx again
keep going lets goo!!
Nice One Go you can do it become a professional Lua Scripter!!
(I am still learning the basics)
mine is better
local touchedPlayers = {}
game.Workspace.Part.Touched:Connect(function(hit)
local plr = game.Player:GetPlayerFromCharacter(hit.Parent)
if plr == nil then return; end
if touchedPlayers[plr.Name] == true then return; end
plr.Character.Humanoid.Speed = plr.Character.Humanoid.Speed*4.5
touchedPlayers[plr.Name] = true
end)
@@hetnianabathis is equally bad 🥶
These lessons are very epik keep it up
Glad you like them!
ngl RUclips shorts is the last place you should be learning to code at
This is a great tutorial on inheritance, I remade work at a pizza place with this, thank you 🙏
This is a good video and I love roblox and roblox studio. I create many game, and I wrote script this is a amazing feel.
don’t learn from RUclips shorts 🥶🥶
Idk but most of the tutorials out there well just tell you the basics of lua and let you go
BUT THIS ... NAH ITS MASTERPIECE
Tysm! Now i finally understand how to use events ☠ ☠
Glad I could help!
You are so cool man, may God bless you all
Actually very helpful thank you
cool. now i can easily do flashlight back easingstyle tween. thanks!
you make so much sense
Thanks
This looks so Funnn
Thank you so much now I know how to script
Scipt parented to the Baseplate hurt me
fr
Ikr theres literally something called ServerScriptService lmao
this video when it'll probably confuse the person watching it rather than teach them
the parent got touched??!
Nega watt 💀😭
You might as well just do ‘local printMessage = print’ to turn the variable into the print function lol
Local baseplate = script.Parent
baseplate.Touched:connect(function()
Print" I like BBC"
end
Bro could of just said print(“I like pizza”)
Nevermind I just saw .touched
could of done function printMessage(message) and printMessage("I like pizza")
@@SkuppyGamezwith print(message) in the fonction*
@@SkuppyGamezmessage is a variable so u need that
@@allthemallows the "Message" variable is declared when the function is called, so there is no reason for it to be outside of the function
thank you, very helpful!
Glad it was helpful!
@@TheRobloxCoach yeah bro!
I’m learning JavaScript aka Minecraft script. And this looks way easier than JavaScript. I actually understand it a bit.
You should've also showed anonymous functions bc idk why u need a different video for the same topic
people got so low attention spans now they got to watch 30 second tutorials that usually last a few mins. Good tutorial tho
Thanks man
Is roblox[] just Python? Bc I have a Python book that might be helpful for future use.
"Script.Parent.Touched"💀
bro thats the script fym
@@LiteralBanishedArtistyou can also do script.parent.parent.touched
Local message = "i like pizza"
Thanks for your help
I get it that all you are starters, in about 3 years or so you’ll learn LuaU perfecrly
Spends so much time explaining.
Can you explain what is local and what is function
Local means only you can see it and function is a short piece of code that can be called with script.Parent.(event).Connect:"function"()
@@sonic176yt7thanks
local message = "I like pizza"
local part = script.Parent
part.touched:connect(function()
print(message)
end)
this isnt really teaching how to script, this is just telling you what to type
-your helpful❤-
Roblox scripting in 30 seconds.. meanwhile length of video: 59 seconds 💀
it will still print even if you didn't touch it, you should also add a line of code that will only work if the player touches it
Mhm correct.
Dont forget to add a wait() after the script.parent thing or else it will crash studios
Got a question. Doesn't the local message variable have to be in the scope of the function?
bro why do all my favorite youtubers never
blow their nose or unclog it 😭😭
Are you able to make functions in module tables? Id like to make my UI scripts much cleaner using module scripts and tables if possible.
lets say u have a table
local mt = {} -- My table
-- Now if we wants to make a function to that now we can assign functions to that table
function mt:myFunction() end
-- or
function mt.new() end -- constructor if u know what that means.
-- 2 ways to link functions to tables
Is this what u asked for?
also if u wanted to make a UI Library for UI then make sure to return the table like a module script
local mt = {}
return mt -- end of script
It probably help me to learn script
Excuse me coach, how do I make this: .=. I’m trying to make a game but I can find the right Dot/. That’s between the equal signs
Is it weird how I understood this more than a 20 min vid?….
I'm a little confused by the "local" part, like what does it do ? And when do we need to use it ?
local message = "i like pizza"
function printMessage()
print(message)
end
script.Parent.Touched:Connect(printMessage)
Do you have a long Videos
But is it really even lua if you don’t spam local before everything? Global namespace is overrated tbh
Thank❤
Why would you want to use a function to print something tho i mean just use the default print function you are provided and you did not even show how to use parameters.
hes explaining variables and functions hes not aiming to make it the most realistic script
What is Parent and Children, im confused also what is Connect
❤❤wow
First part is understanding it
Second part is
How do you actually use it?
Thanks!
i dont understand at all what the names do 😭
You can choose them. For example:
local Hello = 13
if Hello == 13 then
print("It is thirteen")
else
print("It is any number but thirteen")
In this scenario, you choose to make Hello be equal to 13. It could be bananas, apples, gold bars, etc.
How do I make the script check for a value constantly like I have a folder in startercharacter scripts and I want a loca script to always be checking for a value that is on inside of that folder
Get a reference to that value
Woah
Thank You
Bro could have used a anonymous function
Hi coach i was tryna see if u can help me make a racing game
Why are we putting a script under a part?
Cause .Touched event is for parts.
@@dimxx987 no idiot, we should be having server scripts under server script service that handles workspace part manipulation. We shouldn’t get into the habit of putting scripts under parts.
quotations!!! YOU MISSED THE QUOTATIONS!!!!!!
how do you zoom in the script ?
ctrl + mouse scroll
Or this Ctrl + Z
Yo bro i opened roblox stusio and the screen wasnt inside the toolbox thing and i had to resize it inside and whenever i try clicking enter it just selects all
Edit:plus if i make a new script the print doesnt show up and when i click the minus button the print is outside
How to climb a wall:
Just climb it
How to script:
Parent.local.scriot.wall.baseplate.fuction.print
Just learn to script
could've just done script.parent.Touched:connect(function()
print("I like pizza")
end)
If you are using the function outside the event, Is better for it to have its own definition. For example, you reload a gun not only by pressing 'R', but also by emptying your mag, so two different situations where the function Will be calles.
is this a local script or just a script?
what do u even use function for?
well whats the point of printing the message.. what will it do in a roblox game? and strings are pointless too. it does nothing but give output
its only for understanding
Printing is used for debugging/testing mainly. Say for example something isn't working in your code, but youre not entirely sure where? Well, thats where printing can come in handy, because itll tell you in the output once it reaches the line with the print in it. So for example, if you have an if statement with some code in it, and its not running, you could put a print at the start of your if statement to check if your script is actually reading that if statement, and if the condition of the statement is true. If for whatever reason, it doesnt print to the output, then boom, you just discovered part of your problem.
As for strings, they are also not pointless. A lot of things on Roblox require text(AKA a string). Need to rename something like a part for example? Use a string.
printing is used for finding errors and strings are used for stuff like links, player name, getting service, wait/find child, etc
You use print a lot, not for the players, but for you as a dev, It helps checking errors, It helps checking wether the Code stops in some place, It helps to check if the outputs are valid.
And Strings are SUPER important, anything you see as text in any place, Is a String, even numbers, as their binary format can't be just simply shown.
When I use function it say I need to use end
The "end" closes the function so it doesn’t collide with the code that can be below it.
why dont yall use "local function blahblah()
"
Still didn’t work for me 💀
hey how to do more than 2 rows in roblox studio pls reply I need it fast😢
what is the sound track?
bro said "30 secs" but it was 58 secs🤣🤣🤣🤣
for people is finding in Comments:
Localed script credit
Copy give majdbebo:
Scripting youtuber:
Script:
local message = "i like pizza"
function printmessage()
print(message)
end
script.Parent.Touched(printmessage)
how do i get up the script part to type
Is function like def in python?
Is this python or Lua
Lua
But what’s the point of a variable ?
suppose ur building a shooting game. you made a gun. the speed of the gun shooting is 2 second. u enter that in a variable and use the variable in many other places of the script.
Stores data in an accesible way. Let's say you have a value object in script.parent.folder1.folder2.module.value, you can store that reference into a variable, and then, you can access that data from your variable.
baseplate doesn't shop up for me do you now why
thats weird
fire logo made in canva maybe? me tooo mannn
This makes no sense
OMG! I HAVE BEEN TRYING TO LERN CODE FOREVER AND I WAS EXPERMENTING AND I JUST MADE A DEATHBLOCK! BY MYSELF WITH NO TUTS!!!!!!!!!!!!!!!
Good job
is it actually that easy?
What does local stand for ?
Variable declaration only exists for that scope and lower levels. There's the global scope, when you create a function, the function Is part of the global scope, all variables you create inside that function are part of the function scope. Not using 'local' forces the variable to be global scope, which Is not always the case, so in short, always use 'local' just to be sure.
ok now im know how print work
print is a basic one even I learned it in 1 day without any tuts when I was a starter
BRO WHY DID U LEARNED IN 1 DAY ITS SO EASY
@@foxiwq its hard
@@el_turajust think of it simply
@@el_turafor instance to print a variable you could do
local variable = “Hello World”
local variable2 = “, yes”
while true do
wait(1)
print “(variable)..(variable2)” I think this is lua syntax I use c++ or c# tho
This would print Hello World, yes
i wanna know how to run it tho :C
Ima put boo instead of i like pizza >:)
I JUST ATE PIZZA-
this us hella confusing my brain isnt braining
I don't understand
This is roblix scripting in 30seconds hard core😅
Who wanna team up with me and make a game
All i know is no.parent🗿
woa
my brain: 🧐🧐