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

bbbbbbwhat are locals without any input in it supposed to do?

Asked by 5 years ago
Edited 5 years ago

i added the b's on the beggining coz title was too short. pretty simple but im not sure if i understand what it does. what i mean is something like this

1-- script
2local abc
3-- the rest of the script

and nothing else

3 answers

Log in to vote
3
Answered by 5 years ago
Edited 5 years ago

This is used so you can set the data of it afterward. E.g.

1--//Variables
2local target

This could be used as a turret or gun.

01--//Variables
02local target
03 
04local bullet = game.ServerStorage.Bullet:Clone()
05bullet.Touched:Connect(function(hit)
06    if hit.Parent:FindFirstChild("Humanoid") then
07        target = hit.Parent
08    else
09        target = nil
10    end
11end)

You could use this technique later. E.g. You could make a textbox that shows what the target is

01--//Variables
02local target
03 
04local bullet = game.ServerStorage.Bullet:Clone()
05bullet.Touched:Connect(function(hit)
06    if hit.Parent:FindFirstChild("Humanoid") then
07        target = hit.Parent.Name
08    else
09        target = nil
10    end
11end)
12 
13local textBox = script.Parent
14if target ~= nil then
15    textBox.Text = target
16else
17    textBox.Text = "No Target"
18end

So basically, the variable will hold the value nil until it has a value and you can then call that variable later in the script.

0
Pls accept, I took a lot of time in making this explanation kingblaze_1000 359 — 5y
0
ok thanks and sorry for late accept i was asleep TFlanigan 86 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

It is just a placeholder for a value that does not exist yet.

0
Indeed. It is the equivalence to: local abc = nil Thetacah 712 — 5y
Log in to vote
0
Answered by 5 years ago

All it is is a variable that you made with no value, but you can change the value of it in a function or an event later.

Answer this question