What does a script start with?

Im new and i have no idea what a script with.
I know it has to end) but what is script. ?
What is Parent and Child ?

3 Likes

Check out the Intro to Scripting video!

Scripts can kinda begin with any valid Lua code. It’s a pretty flexible language.

Child/parent relationships aren’t really related to scripting, but rather the game hierarchy (i.e. structure). Think of it like boxes. You have a BIG box (the parent), and a bunch of smaller boxes inside the big box (children). A little box’s parent is the big box. A box (or object in the game) can have 1 parent (or sometimes no parent) and any number of children.

5 Likes

It depends what you want the script to do; there’s many different functions. Find more about them here:
https://developer.roblox.com/articles/Understanding-Functions-in-Roblox

Scripts & Scopes


In all programming, there are always scopes.

What are scopes?
Scopes are literally a boundary for variables. In the beginning of a script, it is always a global scope and nothing is required to be started with. Local scopes restricts variables in their own scope. Here’s an example of scope:

varG = 1337
local varA = 0
local varB = 10

print(varA, varB) -- 0 10

function scopeFunction()
    local varC = 1328
    print(varC) -- 1328
    if true then
        local varD = 9
        print(varD) -- 9
    end
    print(varD) -- nil
end

print(varC) -- nil

There are no obligatory beginnings of a script, but you will always have to index the values in order. From line 1 is the first line executed before moving to next lines. Functions, loops, if/else statements, etc. all create a new scope, be sure to close it after typing one.

Ends are required for closing a scope.

Parent & Child
These properties can be found in the explorer, but importantly, you can find parent. The explorer is a hierarchy of objects. If we insert a part in the workspace, the part is the child and the workspace is the parent of the part.

Oh, and if you don’t know what an explorer is, you can find it in view tab in Studio. It is labeled “Explorer” on one of these buttons, it is at the left-most position, I think.

2 Likes