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 4 years ago
Edited 4 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

-- script
local abc
-- the rest of the script

and nothing else

3 answers

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

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

--//Variables
local target

This could be used as a turret or gun.

--//Variables
local target

local bullet = game.ServerStorage.Bullet:Clone()
bullet.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        target = hit.Parent
    else
        target = nil
    end
end)

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

--//Variables
local target

local bullet = game.ServerStorage.Bullet:Clone()
bullet.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        target = hit.Parent.Name
    else
        target = nil
    end
end)

local textBox = script.Parent
if target ~= nil then
    textBox.Text = target
else 
    textBox.Text = "No Target"
end

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 — 4y
0
ok thanks and sorry for late accept i was asleep TFlanigan 86 — 4y
Ad
Log in to vote
0
Answered by 4 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 — 4y
Log in to vote
0
Answered by 4 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