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

What does it mean when some variables are defined without an "=" ?

I'm new to coding and so while trying to learn what certain commands I have seen a few scripts in which there will be a line like

local player

or

local humanoid

I wasn't sure if they had a purpose so I tested those scripts removing these lines and the script would immediately crash. What is the purpose of these, and what does it mean when they have no "=" to define them as something else?

2 comments

0

writing "local player" is the same as writing "local player = nil", it's only purpose is to assign the variable

0

No problem!

1 answer

✓ Accepted answer

Those are variables that will be referred to later. Here is a section of my scripts that I apply it in:

local mainDataTable  -- here I name the variable
		
local success, message = pcall(function()
									 
		mainDataTable = mainDataStore:GetAsync(specialKey) -- here I assign it a value. If I had done local mainDataTable inside this function then the rest of the script would not be able to use it. So I set the variable first then gave it a value

end)

Hope this helps and have a great day scripting!

1 comment

0

That explains a lot, thank you!

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