#I don't understand this

1 messages · Page 1 of 1 (latest)

round hearth
#

Im reading and watching some guides to learn how to script, but i don't undersatnd How from this code, the player's name appears in the console output, Because when I make functions when calling them I have to write the information (I don't know if I explain myself)

onyx adder
#

You understand that you can pass values to functions. This is formally categorized under "arguments & parameters", where the values you pass are dubbed "arguments". Functions in Luau are first-class, meaning they're treated like any other datatype. This means functions can be passed as arguments like any other value

round hearth
onyx adder
#

You're passing a function literal to RBXScriptSignal:Connect, a higher-order function which accepts a single function as an argument

#

That function gets store in the event object, and when Roblox's engine encounters the code that should trigger the event, it executes the stored functions within the event with relevant arguments

#

Each function is executed asynchronously

topaz trellis
#

He said he just stared man i don't think he understands this... I barely do...

onyx adder
#

These tutorials don't teach you anything, lol

onyx adder
#

No differently from how you would call the function yourself

round hearth
#

i think i understand a lil bit but i mean, idk how to learn propely beacuse the videos dont explain that

topaz trellis
onyx adder
round hearth
remote thunder
onyx adder
# round hearth alr

Variables
Datatypes
Arithmetic operators
If statements
Relational operators
Logical operators
Boolean logic
Scope
Loops
Functions
Arguments & parameters
Higher-order functions & callbacks
Tables
String library, miscellaneous operators
Task & coroutine library
Events (RBXScriptSignal, RBXScriptConnection)
Client-Server model
Algorithms and data structures

remote thunder
onyx adder
#

Doing that effectively would take ~20-30 minutes via video call

#

I've had this discussion before, lol

remote thunder
remote thunder
#

;compile lua lua print({})

graceful thicketBOT
#
Program Output
table: 0x6391504acd40

remote thunder
#

that's what it actually is, but roblox is convenient, it knows what the player object is and prints its name instead of that.

onyx adder
#

print invokes the __tostring metamethod. Instances implement it to return the instance's name

round hearth
remote thunder
#

it's just the fact that roblox has a bunch of conveniences, and because code runs extremely fast, you don't really notice

#

async is not 2 scripts running at the same time. that'd be parallel lua. async has more to do with the task scheduler/ timer thing

round hearth
#

is only for large codes we can notice i suppose

onyx adder
round hearth
#

And how do you recommend I learn? By watching videos? By reading the Roblox wiki?

onyx adder
#

It is what Roblox provides through its coroutine and task libraries

round hearth
#

alr

onyx adder
#

Ask questions here

remote thunder
onyx adder
#

If anything, use YouTube for reference material—a means to start searching for articles on things

remote thunder
#

learn a new programming word every day and you'll reach our level in what, say a year tops? there's lots of words to learn, no different from any other skill.

onyx adder
#

Terminology is very important

onyx adder
#

Documentation and articles are some of the most powerful resources out there. They're technical as a byproduct, so knowing how to interpret them is key

#

It also goes a long way in understanding what you're doing and what you're writing

round hearth
#

Alr

round hearth
#

I didnt understand a part of this code on roblox wiki

#

local fruitName = "Chocolate"
local fruitTable = {
    Lemon = "Yellow",
    Apple = "Red",
    Orange = "Orange"
}

local function getFruitByColor(color)
    local fruitName
    for key, value in fruitTable do
        if value == color then
            fruitName = key
        end
    end
    return fruitName
end

local fruit = getFruitByColor("Yellow")
print(fruit) -- Lemon
print(fruit .. ", not " .. fruitName) -- Lemon, not Chocolate

#

on the for boucle

jade steepleBOT
#

studio** You are now Level 5! **studio

round hearth
#

what is key and value

#

@remote thunder (sry if i bother u, tell me if u dont wanna be ping)

remote thunder
#

look at fruit table

#

also play with the code

#

you're not expected to understand it right away immediately, no one does. so play with it and find out how it works.

#

if i just tell you, you wont learn anything.

round hearth
#

that's true

#

ok

round hearth
#

and

#

Yellow a value

#

so

#

for each key in the table and their values,
we verify if the value is a color. Then the variable fruitName is also a key, so we return "chocolate".
Then we print the local fruit (which has the value from the function that searches for a yellow fruit). That's why the first result is "Lemon", and the following print concatenates the same result as before with fruitName, which is equivalent to "chocolate".
I think I just understood.

remote thunder
#

use what you learned and make something new with it?

#

maybe do other things with it too?

#

like make a vegetable table?

#

count how many fruits there are?

#

make then build on it and give each fruit a value or something

#

like, you dont pay me enough to be your teacher and i'm sure you can come up with your own homework to assign yourself

#

that's how you learn.

#

the only reason i dont need to do any of that is because i've already done all that.

round hearth
#

alr my bad sry

remote thunder
# round hearth alr my bad sry

what i'm trying to show you is called self-directed learning and is one of the most, if not the most important skill you could ever possibly learn

Autodidacticism (also autodidactism) or self-education (also self-learning, self-study and self-teaching) is the practice of education without the guidance of schoolmasters (i.e., teachers, professors, institutions).

#

if you're able to teach yourself with nothing but online resources, documentation etc, then you have infinite capacity to learn without the need for waiting for anyone, paying people to teach you etc

#

not to mention, when you ever reach a high enough skill level in any field, you literally won't have a choice since there won't be anyone who is able to teach you anything you don't already know, so you have no choice but to progress further on your own.

#

it's tough, but there's no limits to what you can learn or how good you can get if you understand and apply this principle

round hearth
#

i will do my better

topaz trellis
remote thunder
# topaz trellis Quick question: let's say I want to do something but I don't know what tools to ...

no, start with google. tutorials are good for giving you initial direction. you then take all the concepts and put together your own while looking everything up in the docs to see what they do if you don't already know what it does. that way, even if you copy+paste wrong, you aren't relying on the tutorial for free working code, you're only relying on it for basic concepts, ideas, approach, and searchable keywords you can further research.

#

ai goes a lot the same way, it will give you concepts and ideas, theoretical approaches, and searchable keywords. using ai only becomes a problem when you expect it to produce functional code instead of taking its approach and searching all of its keywords.

topaz trellis
#

Very useful advice thank you

remote thunder
#

imagine that, only 30 years ago you needed a phone book to look up contact info for businesses and people. an actual physical book.

#

with actually 1000's of pages.

#

if you wanted to look up anything on "wikipedia", those were called encyclopedias.