Explaining Lua Tables as if You Were 5
HTML-код
- Опубликовано: 10 сен 2024
- 50% OFF COUPON WITH "DOUBLEBYTE" (ends in 3 days):
linktr.ee/Byte...
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/...
You’ll also get 20% off an annual premium subscription!
discord: / discord
wondered how to make a main menu in roblox studio? or how to create a shop which has working GUI? ive made lots of 2024 roblox scripting tutorials about all the different bits of roblox to give you some up-to-date information about all of its properties and events.
my goal is to simply give some insight on how to use the various features and instances roblox studio, and show you some fun stuff you can do with them. thanks for checking out this roblox scripting tutorial :)
Get all of my knowledge in one package: linktr.ee/ByteBlox
The reason why it gave you the "Attempt to call a nil value" error was because you did tableName.functionName() later, not because of the type of key.
No they don't. They work the same as other programming languages, the key difference is that Luau is not restrictive with it's variable types or table/array structure by default. You can fix this by setting the script to scrict mode or by limiting or defining table structuring.
The other problem which people might think is an issue is the apparent loss of ordering. This is not an engine problem, it has to do with time of execution. This can be fixed by using indexes.
This tutorial was poorly planned and has mistakes, so they look a lot harder than they actually are. It's ok to do things on the go but please, prepare beforehand to avoid misinterpretations because people watching these videos usually have little to no experience with programming.
Just looked at what strict mode was because I didn’t know, but I’m still a tiny bit uncertain of it’s uses.
Is it just used when making classes and functions so you know what type each value/param should be every time? Or are there more uses of it?
@@haxking2352it makes the typing strict like in other languages like C, so you can't make a variable with type number and then assign a string to it or something like that
@@someonerandom9939 ah that explanation is clearer than what I read online, thanks
being able to implement instances as dictionary keys has improved optimization a TON for my games.
Not separating tables and maps is stupid. Not having an inbuilt. Length for maps is stupid. Meta tables are really dumb considering it doesn't trigger on assignment which, I guess that js meant for speed but it still could have been implemented
idk if anyone's said this but i personally reaaally like your thumbnails, especially how they have a dotted frame around it gives them a nice touch, they look cool !
10:00 You were calling a function by the name of functionName when you changed the key to 1. You would have needed to do `tableName[1]()`
i would like to bring up a problem, it will certainly print out the function with a index of 1, but you called the tableName.functionName() which doesnt exist anymore at 9:50
yeah thats what i wanted to point out too
I saw that too
Functions with a key that is a number can be run. I like your teaching style, but at least teach things that is correct.
He forgot to remove the line tableName.functionName, which he could have used the index it would work, but the functionName does not exist.
well, this is understandable, a table is the only data structure in Lua.
Its not just Roblox though. Lua is just super open what you can do with arrays/dictionaries.
Also just quick information for those confused about names:
"Table" is just a higher order data type that arrays and dictionaries are based off.
Arrays are "tables" that have numerical indices (usually implied, as in the first example).
Dictionaries are "tables" that have strings as indices.
You can also mix and match between index types, you can have some numbers, strings, etc..
However in Lua, you can place whatever you want as a key. Objects, other tables, functions, booleans, etc.. I believe these would be a form of dictionary.
4:29 its because the table names were written in alphabetical order, and three comes before two in that order since the "h" in "three" comes before the "w" in "two", hence why it looked like that!
I really don't get the point of this video. They are not unecessarily complicated, they are only extremely flexible, and I find myself using this flexibility all the time.
In a game, what will a table be used for?
PLEASE make a video about metatables, I don't understand them and I learn extremely efficiently from your videos!
As it seems tables print in alphabetic order by default
I actually use metatables in almost all my projects a video about it would be awesome but unfortunately you're too tired so maybe later or never
How do you manage tables on a big Roblox Studio project?
I want to know if it's possible to use dot notation for automatically created tables within a Module Script.
Those tables are only filled up during run time, so what are my options here ByteBlox?
You should fully read the errors you get, lol. But very good content tho
12:17 why though? Will that make an apple turn red? What would you achieve by writing that?
…. I want to see how things you write can be applied to the game.
Thanks. Tables didn't make a lot of sense to me.
Hey thank you for helping us cloud you Explain the Buffer libary in roblox and mybye the Module yk
I like tables
i really like watching your tutorials, i've always wondered how to do tables. it was the only thing i didn't know how to use for years. recently i discovered you and i wanted to ask if you could make a tutorial on tables but you already did it! thank you.
How have you coded for years without knowing tables?
@@JoaoMPdS tbh idk, never needed it
@@multistronomy I don't know any script where I didn't use them. U use them on module scripts, on for loops. Crazy
@@JoaoMPdS whoopsies
What is this video my bro?
How are tables complicated?
They are an array and a dictonary
So underated W mans
Can u teach us about " Strings. " ?
The reason it doesnt work at around 9:45 is because you are running a function FunctionName which does not exist as the string was changed to a number, imagine forgetting to change it
I assume tableName[1] would work, but i really am not sure
it gave me an error at the first part. it gave me " table: 0x94a50b1edb0dc5cc "
I'm having the same problem, I tried to solve it multiple times, but my table still won't print, btw, if you solved the problem how did u do it???
Im trying to make a table with the players in the server and wanted it to print the first player that is listed, here is the script, pls tell me for corrections:
local pla = game.Players:GetPlayers()
local tab = {
pla
}
print(tab[1])
GetPlayers is already a table. You don’t have to make another table, you can just do pla[1]
this is why i am the tables
I am not In Pairs Script, I AM THE TABLES.
I AM THE ONE WHO REQUIRE()
Viewers who *ARE* 5 and are watching this video:
am i a joke to you?
Tables make sense but what about.. table flip?
OH PLEASE DO METATABLES!!!
Nah bro that’s like some matrix stuff
@@byteblox100 PLEASE!!! I NEED TO KNOW ABOUT THEM 😭😭😭
@@emotionallydeprived1889Metatables are used for OOP and warning something does not exist to the player via probably UI (You don't know what exactly will contain in a table) or to make them fancy. That's it. So you should only understand the __index and __newindex metamethods. The rest is BS
tables are simple
do you have a discord for people who need help with scripting?
discord.gg/byteblox
Wait the link expired lol, just check the descriptions of recent videos
Its arrays
key? not index?
Both work
buddy stop doing bad tutorials you're not born to teach this is an poor table tutorial, almost all ur tuts are bad you need to have responsability you're teaching new people how to be bad programmers
I'm 4 so I can't understand 💀💀💀💀💀
tables suck on roblox
When you printed out the first value, print(tableName[1]), that told me exactly how to make a dialogue script for my shopkeeper!, heres the script i made, as i already have SOME experience with scripting. local hum = script.Parent:WaitForChild("Humanoid")
local anim = Instance.new("Animation")
local anim2 = Instance.new("Animation")
local anim3 = Instance.new("Animation")
local tableVar = {"hi!", "hello.", "hey! :3", "hi there. >:3", "i uh. broke the icecream machine again!!.. sowwy 3:", "hawoo!!! :3", "hihihihi welcome to me shop!!!! :3", "super funny text that you WONT see!!... or you will, idk! :3", "awh man... me icecream spill on ground... wutever!! i get other one!! >:3", "what would u like???? :3!!", "hai there!!!", "haaiii there!!! :3"}
local messages = #tableVar
anim.AnimationId = "rbxassetid://16393685271"
anim2.AnimationId = "rbxassetid://16394153075"
anim3.AnimationId = "rbxassetid://16394762243"
local playanim = hum:LoadAnimation(anim)
local playanim2 = hum:LoadAnimation(anim2)
local playanim3 = hum:LoadAnimation(anim3)
local numbertick = math.random(1, 10)
local oldnumber
wait(numbertick, print(numbertick))
playanim:Play()
script.Parent.Head.Shout.Message.Text = tableVar[math.random(1, #tableVar or messages)]
warn(script.Parent.Head.Shout.Message.Text)
while script.Enabled == true do
local funnynumber = math.random(1, #tableVar or messages)
oldnumber = funnynumber
wait(math.random(playanim.Length + 2, playanim.Length + 5))
playanim:Play()
script.Parent.Head.Shout.Message.Text = tableVar[funnynumber]
print(funnynumber or oldnumber)
warn(script.Parent.Head.Shout.Message.Text)
end. Thanks for all of the small tips! They still help!