Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

0

Pls accept, I took a lot of time in making this explanation

0

ok thanks and sorry for late accept i was asleep

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

1 comment

0

Indeed. It is the equivalence to: local abc = nil

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.