I have noticed that some scripters create variables on the same lines as each other. Example:
local one,two,three = false,true,1 --I put random variables in
now that makes sense (at least, I think). My question is, is the order they are defined in the same order they are listed? In otherwords, is it the equivilent to this:
local one = false local two = true local three = 1
Also There are some cases where declaring multiple variables on the same line DON'T make so much sense, an example of this would be part of raycasting (Source:www.robloxdev.com/articles/Making-a-ray-casting-laser-gun-in-Roblox)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
What does the part mean, and what does the position mean? And how does roblox match the variables to their definitions?
The reason for multiple variables being assigned in the FindPartOnRay
in one line is because said method returns. It returns more than one item, so you can assign each variable in the order you return them in. Take this for example:
local function OneTwoAndThree() return 1, 2, 3 end local one, two, three = OneTwoAndThree() print(one, two, three) --> 1 2 3
It prints 1, 2, and 3, and in order because that's the order in how it was returned.