For example this variable has 3 variables hit,position,normal does that mean that 3 of these variables are the same?
local hit, position, normal = Workspace:FindPartOnRay(ray, ignore)
For example this variable has 3 variables hit,position,normal does that mean that 3 of these variables are the same?
local hit, position, normal = Workspace:FindPartOnRay(ray, ignore)
In Lua you can return multiple values in a function (this is quite rare in programming languages) and other languages get around this by returning an array/list of values.
In the case of FindPartOnRay if a part intersect the ray then additional information is included that developers may or may not use.
I think you might be confusing a function which can return different types with a function that can return multiple values.
Example
-- multiple return <string, string>
local function a() return "A", "B" end
print(a())
-- different return types <string, boolean>
local function b(val)
if val then
return "A"
else
return false
end
end
print(b(true))
print(b(false))
Hope this helps.
This discussion is preserved as it was. New answers, comments, and votes are closed.