Hello!
So I don’t know if this is the right category. But I wanted to teach some newer users how to lua code basic functions with some comedic background by our friend Steve who wants to eat his pancake but in coding!
Today we will be working on making our first line of code in Luau which is the programming language that is used in Roblox Studio. We will learn basic functions and printing on Luau.
What is a function?
Imagine Lua is a little chef in a kitchen.
If you want the chef to cook something later, you must teach them the recipe.
That recipe is called a function.
For example:
Lua! I have a recipe for you
function makeSandwich()
Lua then write down your instructions
print("Making a sandwich...")
print("Adding cheese...")
print("Sandwich complete!")
Inside the function, you put whatever you want Lua to do
Then you can close the code by using
end
To make lua actually use the recipe
makeSandwich()
So here is a quick summary of how to use functions to make our friend Steve enjoy his pancake.
Hope you enjoy!
-- Function: Robot picks up the pancake
function pickUpPancake()
print("ACTION: Acquiring pancake from plate.")
end
-- Function: Robot analyzes the pancake
function analyzePancake()
print("ACTION: Conducting structural and quality analysis of pancake.")
end
-- Function: Robot simulates taking a bite
function takeBite()
print("ACTION: Simulating controlled bite of pancake.")
end
-- Function: Robot completes the task
function finishPancake()
print("ACTION: Pancake consumption sequence completed successfully.")
end
-- Execute the sequence in order
pickUpPancake()
analyzePancake()
takeBite()
finishPancake()
print("SYSTEM: Pancake Protocol Complete.")