Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What do these words mean?

Asked by 10 years ago

I am a beginning scripter and I have scripted a button door. That was easy. I would like some help on what some of these words mean that are important to a detailed script.

1.) Function 2.) local 3.) instance

1 answer

Log in to vote
0
Answered by
Hybric 271 Moderation Voter
10 years ago

function = A piece of code that can be run multiple times, or called when a certain event happens in the game

Example:

function Hi()
script.Name = "Example"
local p =Instance.new("Part")
p.Parent = Workspace
p.Size = Vector3.new(80,80,80) 
p.Shape = "Ball"
p.Position = Vector3.new(0,10,0)
p.Anchored = true
end

while true do
wait(5)
Hi() -- The function is named Hi, so the function name will go here with "()". It is for using a large segment of scripting into one line, or for functions like onTouch(), those are Different.

local =used for saying what what means, Example:

local hi = Workspace.Part -- hi shortened that code part just into "hi"

MAINLY IS:
used when defining variables, but can also be used with functions. The keyword makes sure that the locally defined variable/function is deleted when the scope of creation (the scope where the variable/function was created in) has ended. It's recommended to use this, due to it being efficient-er and faster than definitions without the keyword. Scopes are started after the keywords do, then, repeat and function and are ended with the keywords end or until.

Instance - *Instance is a code part of Instance.new This creates whatever object in parentheses from Basic object, but in a script. (NOTE: The part created must be from Basic Objects) *

Example:

local i = Instance.new("Part") -- Using local will make it work
i.Parent = Workspace -- Lets say you inserted a part from basic objects, The parts property names and what it equal will be "i.Parent"
i.Name = "Put whatever name" -- Any name you want
i.Size = Vector3.new(number here, number here, number here) -- You have to use Vector3.new() for size or rotation
Ad

Answer this question