开发者

What is ROBLOX Lua scripting? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_开发技巧

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 2 years ago.

Improve this question

I really dont understand what it really even is. Is it just normal scripting or something else?


Lua is a fairly well known and often embedded scripting language.

However, if you're after some basic "getting starting" information on Roblox scripting, check out the Roblox Wiki. (The tutorial's section would probably be of specific interest.)


Lua is a well known scripting and programming language that is lightweight and easy to learn. Many games have embedded it, including Garry's Mod (GMod) and World of Warcraft.

ROBLOX uses Lua to actually create games. Most of the features you see in ROBLOX (like the GUI and building tools) are actually coded in Lua.

I'd recommend seeing games by Anaminus, VolcanoINC and Telamon to see what you could do with Lua.


Lua is a scripting language somewhat similar to Java. Infact, I recall there being a Javalua blend as a scripting language in itself. Lua is probably the easiest scripting language to learn and work with. Its functions are fired by changes specified such as script.Parent.Value.Changed:connect(functionnamehere)

Parents are what the script or item specified is in. Variables work like this:

v = script.Parent.Value

or

d = game.Workspace.ScriptFireValue.Value

If a ROBLOX Solo Game is the source and v's script.Parent's name (script.Parent.Name) is ScriptFireValue then v is equal to d.

The language also includes loops that are recognizable like

lua: while true do

vbs: do while/Loop

java: do while

'for' is a limited loop where it only loops for a certain amount of times. exe.

for i = 1, 10 do
game.Lighting.TimeofDay = game.Lighting.TimeofDay + 1
end

This part of the script will run 10 times before passing on. when u have the part 1 - 10 or 1, 10. The 'end' comes after anything highlighted in blue. Things highlighted will be: for [whatever's in here will not be highlighted] do - Both words only count for one end. while true do while [Something in here that exists or is a value] do - Both words only count for one end. function() if [something exists or is a value] then - Both words only count for one end. else -- Used when the if statement before it is false. When used the 'if' and the 'else' count for one end. elseif -- Used when the if statement before it is false but also calls for another if statement. When used the 'if' and the 'elseif' count for one end.

I think a few more.

Here's an example script I'm writing off the top of my head. The source I'm going off of is ROBLOX's Build/Edit mode in-game.

function KillAllPlayers(clicker)
if clicker.Name == "coolboy10000" then
people = game.Players:GetChildren()
for i = 1, #people do
people[i].Character.Humanoid.Health = people[i].Character.Humanoid.Health - 10000
end -- ends if
end -- ends for - do
end -- ends function

script.Parent.Clicked:connect(KillAllPlayers)

That script if not obvious identified the player who clicked. (clicker). Btw the argument 'clicker' would be identified the cause of the function to be fired. So the cause is because a button was 'Clicked'. So 'clicker' retrieves the person who initiated that. Therefore identifying if the player is a certain person which would allow the process to continue. So if the player's name is coolboy10000 then it will gather all the players and kill them each.

To put a security on that button to where if the player is not coolboy10000 then the player will be killed you could do this:

function KillAllPlayers(clicker)
if clicker.Name == "coolboy10000" then
people = game.Players:GetChildren()
for i = 1, #people do
people[i].Character.Humanoid.Health = people[i].Character.Humanoid.Health - 10000
end -- ends for - do
else
clicker.Humanoid.Health = clicker.Humanoid.Health - 10000
end -- ends if and else
end -- ends function

script.Parent.Clicked:connect(KillAllPlayers)

If there are multiple people to allow to do this function you could do:

function KillAllPlayers(clicker)
if clicker.Name == "coolboy10000" or "coldnature" then
people = game.Players:GetChildren()
for i = 1, #people do
people[i].Character.Humanoid.Health = people[i].Character.Humanoid.Health - 10000
end -- ends for - do
else
clicker.Humanoid.Health = clicker.Humanoid.Health - 10000
end -- ends if and else
end -- ends function

script.Parent.Clicked:connect(KillAllPlayers)

Or if there is a specific person who should have a separate punishment:

function KillAllPlayers(clicker)
if clicker.Name == "coolboy10000" or "coldnature" then
people = game.Players:GetChildren()
for i = 1, #people do
people[i].Character.Humanoid.Health = people[i].Character.Humanoid.Health - 10000
end -- ends for - do
elseif clicker.Name == "Person299" then
clicker.Head.Position = clicker.Torso.Position
else
clicker.Humanoid.Health = clicker.Humanoid.Health - 10000
end -- ends if and else and elseif - then
end -- ends function

script.Parent.Clicked:connect(KillAllPlayers)

Yeah that's just the basics :/ There are tutorials out there. Mostly on ROBLOX free models. I say you should study some free scripts and learn how they work and stuff. This is just the basics. There is a tutorial on ROBLOX. Just search in Free Models scripting tutorials. Some dude wrote in scripts how to script. It's pretty long to read but that's how I learned.


Roblox is a gaming website where the users make the games using "Roblox Studio". It's almost like a super complex virtual Lego. To interact with your parts(anything in your game) you make scripts that are written in the language "Lua".


Roblox Lua is Lua 5.1 in Roblox's Data Model.

Roblox Lua Scripting is the act of writing in a script in Roblox Studio.

Their scripts are actually objects with embedded code inside of them. They're placed inside of roblox's basic data model and are used for creating and controlling objects, data, and therefore game-play.


I will not repeat what others have said, and say something else instead. Unlike vanilla lua, ROBLOX lua (also known as rlua) is a modified version of lua.

ROBLOX has implemented different kinds of c and l closures such as tick, wait, delay, and so on, which is why it is a modified version of lua.


Roblox Lua scripting is an embedded coding language to add features to your game. It is easy to learn and is a loose interpretation of modern day game programming. Its an overall great language and I highly recommend it!

https://roblox.fandom.com/wiki/Project:Home https://devforum.roblox.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜