Lua Help: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Ben
Link the DHTML page here!
 
(73 intermediate revisions by 14 users not shown)
Line 1: Line 1:
__NOTOC__
<noinclude>__NOTOC__ {{clear floats}}</noinclude>
{{TitledBox/start|heading=<noinclude>{{CatUp|Main Page}}</noinclude>{{CatItem|luaCode.png|Lua Help|Roblox Lua|Making your maps do crazy things}}}}
[http://www.lua.org Lua] ([http://www.lua.org/about.html#name '''not''' "LUA"]) is a simple programming language that is used in Roblox to add in customized content, like cars that drive, weapons, planes, random terrain, and whole games, and much more!


{{CatUp|Main Page}}
This <noinclude>page</noinclude><includeonly>section</includeonly> provides tutorials to help users to learn Lua.


{|
There are often multiple tutorials on the same subject, so if you don't understand something in one of them, try another!
|-
| valign="top" style="padding-right: 14px;" |
<div style="margin-left: 10%; margin-right: 10%;">


Lua is a versatile, interpreted programming language with a simple grammar. Because Lua can easily be embedded into applications, it is frequently used in games, such as World of Warcraft, Far Cry and Baldur's Gate.
If you still don't understand something, you can ask in [https://discord.gg/CHFK7eXXMY the Roblox Client Search Discord server] or [https://discord.gg/Jfrdmx3ZwQ the Novetus launcher Discord server]. Note that you're more likely to get an answer if you ask a specific question, and that if you have a problem with a piece of code, posting the code (using [https://www.wikihow.com/Format-Text-as-Code-in-Discord multi-line formatting]) really helps people to find what the problem is. Messages just asking "How do I script?" or "Make me this" are usually ignored.


Lua is used in Roblox by users to add in customized content, like cars that drive, new weapons, etc.
{{TitledBox/subheading|Introduction series - read these first!}}
{{CatList|Script Creation Walkthrough|Script Creation Walkthrough|Creating and running scripts.}}
{{CatList|Flowcharts|Flowcharts|Using diagrams to show the "flow" of a script.}}
{{CatList|Basic math|Basic Math|Working with numbers in a script.}}
{{CatList|String|Strings|Working with text in a script.}}
{{CatList|Bool|Booleans|Working with yes/no values in a script.}}
{{CatList|Variables|Variables|How to hold data in a static reference.}}
{{CatList|Conditional statements|Conditional Statements|Making scripts do different things in different situations.}}
{{CatList|Loops|Loops|Making a piece of code run multiple times.}}
{{CatList|Functions|Functions|Wrapping code in a useful function to be called upon later in a script.}}
{{CatList|Tables|Tables|Storing multiple objects in one.}}
{{CatList|Generic for|Generic for|Using a loop to iterate through a table.}}


See the official [http://www.lua.org Lua website] and the [http://en.wikipedia.org/wiki/Lua_(programming_language) Wikipedia] article for more information.
{{TitledBox/subheading|Other Guides}}
{{CatList|Absolute beginner's guide to scripting|Beginner's Guide to Scripting|If you've never worked with scripting before, look here.}}
{{CatList|Basic Scripting|Basic Scripting|Shows you some of the basics of scripting.}}
{{CatList|How to Script Anything|How to Script Anything|Learn the basic methods to put together any script.}}
{{CatList|In-Depth Scripting Guide|In-Depth Scripting Guide|More ways to understand the dynamics of Lua.}}
{{CatListUrl|http://www.lua.org/pil|Programming In Lua|Guide to Lua by its creators. (partly out of date)}}


==Fundamentals==
{{TitledBox/subheading|Introductions to Concepts}}
{| class="wikitable" width=100% border="1" cellspacing="0" cellpadding="4" style="background-color: #fdd; border: 2px dashed #f00;"
{{CatList|DHTML|Using DHTML|Example of DHTML, a 2007 feature letting you display webpages during gameplay (before GUI was added in 2009).}}
|+ <!-- Comment -->
{{CatList|Beginner's GUI Tutorial|What are GUIs?|This very in-depth guide explains what GUIs are.}}
|-
{{CatList|Introduction to Weapons|Intro to Weapons|An intro into the scripting of Weapons in Roblox.}}
|[[Image:LuaCode.png]] [[Flowcharts]]
{{CatList|ROBLOX Scripting How To: Data Persistence|ROBLOX Scripting How To: Data Persistence|What is data persistence?}}
|[[Image:LuaCode.png]] [[Your first script]]
{{CatList|Data Persistence Tutorial|Data Persistence Tutorial|A tutorial on understanding and using data persistence in your places.}}
|[[Image:LuaCode.png]] [[Loops]]
{{CatList|How To Increase and Decrease Vector3 Values|Using Vector3 Values|Shows how to use math with Vector3s.}}
|-
{{CatList|Leaderboards|Using Leaderboards|Creating your own leaderboards.}}
|[[Image:LuaCode.png]] [[Variables]]
{{CatList|Random numbers|Random Numbers|Stopping the same thing from happening each time.}}
|[[Image:LuaCode.png]] [[Conditional statements]]
{{CatList|How To Make Plugins|How To Make Plugins|Shows how you can make your own Roblox Studio toolbars and buttons.}}
|[[Image:LuaCode.png]] [[Generic for]]
{{CatList|Tools|Using Tools|Creating your own tools.}}
|-
{{CatList|HopperBins|Using HopperBins|The older version of tools, HopperBins.}}
|[[Image:LuaCode.png]] [[Basic math]]
{{CatList|String Patterns|Using String Patterns|What string patterns are and how to use them.}}
|[[Image:LuaCode.png]] [[String]]
|[[Image:LuaCode.png]] [[Bool]]
|-
|}


<!-- Comment -->
{{TitledBox/subheading|Reference}}
{{CatList|Scripting|Scripting|An overview of scripting in Roblox, and a portal for in-depth articles.}}
{{CatList|Function Dump|Functions|A list of all the global functions.}}
{{CatList|Class Reference|Class Reference|All the types of Roblox [[RBX.lua.Instance (Object)|Instances]].}}
{{CatListUrl|http://www.lua.org/manual/5.1|Lua 5.1 Reference Manual|Official definition of the Lua language. (some features not available in Roblox)}}


==Flat Scripting==
{{TitledBox/subheading|Example Scripts}}
 
{{CatList|Cookbook|Cookbook|Large list of small example scripts}}
{| class="wikitable" width=100% border="1" cellspacing="0" cellpadding="4" style="background-color: #fdd; border: 2px dashed #f00;"
{{CatList|How do I create a brick?|Creating a Brick|Basic tutorial on creating a brick using a script.}}
|+ <!-- Comment -->
{{CatList|Debounce|IS:What is Debounce?|Explains what a debounce is, and what it's used for.}}
|-
{{CatList|Restricted Doors|Creating Restricted Doors|Shows how to create a door that only certain people can enter.}}
|[[Image:LuaCode.png]] [[Absolute beginner's guide to scripting]]
{{CatList|One Way Shields|One-way Doors|How to create doors that go only one direction.}}
|[[Image:LuaCode.png]] [[How to make text on a brick]]
{{CatList|Teleportation|How to Teleport|An overview of teleportation of players.}}
|[[Image:LuaCode.png]] [[How to add messages]]
{{CatList|Making an onClicked script|Making an OnClicked Script|Shows how to use the Mouse to trigger weapons.}}
|-
{{CatList|Sounds|Using Sounds|Shows how to use events and work with Sounds.}}
|[[Image:LuaCode.png]] [[Intro to Scripting: Make a Dance Floor]]
{{CatList|How to add messages|How to Add Messages to Your Place|Shows how to use scripts to work with the [[RBX.lua.Message (Object)|Message]] object.}}
|[[Image:LuaCode.png]] [[Explaining Scripts]]
{{CatList|How To Use BodyPosition|Using BodyPosition|Details how to use the [[RBX.lua.BodyPosition (Object)|BodyPosition]] object.}}
|[[Image:LuaCode.png]] [[Scripting]]
{{CatList|PlayerAdded|Using PlayerAdded|How to use the [[PlayerAdded (Event)|PlayerAdded]] event.}}
|-
{{CatList|Using the Chatted Event|How to Create Talking Commands|A guide on how to use the Chatted event.}}
|[[Image:LuaCode.png]] [[Functions]]
{{CatList|How To Make Multi Handles|How to Make Multi-Handle tools|Creating tools with more than one brick for a handle.}}
|[[Image:LuaCode.png]] [[Random numbers]]
{{CatList|How to make text on a brick|How to make text on a brick|How to make words appear above a brick.}}
|[[Image:LuaCode.png]] [[In-Depth Scripting Guide]]
{{CatList|How to Make Conveyor Belts|How to Make Conveyor Belts|Parts that move other parts.}}
|-
{{CatList|How to Make Ramps|How to Make Ramps|Using [[CFrame]] to rotate parts.}}
|}
{{CatList|Terrain_Generation|Terrain Generation|Generating non-random terrain mathematically.}}
 
{{CatList|Random_terrain|Random Terrain|Generating unique terrain randomly.}}
 
{{TitledBox/end}}
== More advanced ==
 
{| class="wikitable" width=100% border="1" cellspacing="0" cellpadding="4" style="background-color: #fdd; border: 2px dashed #f00;"
|+ <!-- Comment -->
|-
|[[Image:LuaCode.png]] [[Built-in functions]]
|[[Image:LuaCode.png]] [[Intro to Scripting: Make an Invisibility Tool]]
|[[Image:LuaCode.png]] [[Teleportation]]
|-
|[[Image:LuaCode.png]] [[How Do I Make Morphs?]]
|[[Image:LuaCode.png]] [[How to Make Conveyor Belts]]
|[[Image:LuaCode.png]] [[Tables]]
|-
|[[Image:LuaCode.png]] [[BrickColor Codes]]
|[[Image:LuaCode.png]] [[How do I make VIP doors?]]
|[[Image:LuaCode.png]] [[How to Make Ramps]]
|-
|[[Image:LuaCode.png]] [[ROBLOX Scripting How To: Data Persistence]]
|}
 
 
[[Category:Scripting Tutorials]]

Latest revision as of 06:13, 30 October 2023

Roblox LuaRoblox Lua
Making your maps do crazy things

Lua (not "LUA") is a simple programming language that is used in Roblox to add in customized content, like cars that drive, weapons, planes, random terrain, and whole games, and much more!

This page provides tutorials to help users to learn Lua.

There are often multiple tutorials on the same subject, so if you don't understand something in one of them, try another!

If you still don't understand something, you can ask in the Roblox Client Search Discord server or the Novetus launcher Discord server. Note that you're more likely to get an answer if you ask a specific question, and that if you have a problem with a piece of code, posting the code (using multi-line formatting) really helps people to find what the problem is. Messages just asking "How do I script?" or "Make me this" are usually ignored.

Introduction series - read these first!
Script Creation WalkthroughCreating and running scripts.
FlowchartsUsing diagrams to show the "flow" of a script.
Basic MathWorking with numbers in a script.
StringsWorking with text in a script.
BooleansWorking with yes/no values in a script.
VariablesHow to hold data in a static reference.
Conditional StatementsMaking scripts do different things in different situations.
LoopsMaking a piece of code run multiple times.
FunctionsWrapping code in a useful function to be called upon later in a script.
TablesStoring multiple objects in one.
Generic forUsing a loop to iterate through a table.
Other Guides
Beginner's Guide to ScriptingIf you've never worked with scripting before, look here.
Basic ScriptingShows you some of the basics of scripting.
How to Script AnythingLearn the basic methods to put together any script.
In-Depth Scripting GuideMore ways to understand the dynamics of Lua.
Programming In LuaGuide to Lua by its creators. (partly out of date)
Introductions to Concepts
Using DHTMLExample of DHTML, a 2007 feature letting you display webpages during gameplay (before GUI was added in 2009).
What are GUIs?This very in-depth guide explains what GUIs are.
Intro to WeaponsAn intro into the scripting of Weapons in Roblox.
Data Persistence TutorialA tutorial on understanding and using data persistence in your places.
Using Vector3 ValuesShows how to use math with Vector3s.
Using LeaderboardsCreating your own leaderboards.
Random NumbersStopping the same thing from happening each time.
How To Make PluginsShows how you can make your own Roblox Studio toolbars and buttons.
Using ToolsCreating your own tools.
Using HopperBinsThe older version of tools, HopperBins.
Using String PatternsWhat string patterns are and how to use them.
Reference
ScriptingAn overview of scripting in Roblox, and a portal for in-depth articles.
FunctionsA list of all the global functions.
Class ReferenceAll the types of Roblox Instances.
Lua 5.1 Reference ManualOfficial definition of the Lua language. (some features not available in Roblox)
Example Scripts
CookbookLarge list of small example scripts
Creating a BrickBasic tutorial on creating a brick using a script.
IS:What is Debounce?Explains what a debounce is, and what it's used for.
Creating Restricted DoorsShows how to create a door that only certain people can enter.
One-way DoorsHow to create doors that go only one direction.
How to TeleportAn overview of teleportation of players.
Making an OnClicked ScriptShows how to use the Mouse to trigger weapons.
Using SoundsShows how to use events and work with Sounds.
How to Add Messages to Your PlaceShows how to use scripts to work with the Message object.
Using BodyPositionDetails how to use the BodyPosition object.
Using PlayerAddedHow to use the PlayerAdded event.
How to Create Talking CommandsA guide on how to use the Chatted event.
How to Make Multi-Handle toolsCreating tools with more than one brick for a handle.
How to make text on a brickHow to make words appear above a brick.
How to Make Conveyor BeltsParts that move other parts.
How to Make RampsUsing CFrame to rotate parts.
Terrain GenerationGenerating non-random terrain mathematically.
Random TerrainGenerating unique terrain randomly.