So I’m wondering what is the purpose of having a question mark inside an argument?
-------------------------------------------------------------------------------
function DoSomething(P: Instance)
end
-------------------------------------------------------------------------------
function DoSomething(P: Instance?) -- Question mark?
end
-------------------------------------------------------------------------------
Appearently its supposed to be an “optional” thing, but what does it do to the code?
The question mark means variable or nil, in this case that variable can be an Instance or nil.
Does it affect the code?, no, the types in the script don’t affect the way it works, it just makes it easier to read and edit.
It’s common in Lua for function arguments or other values to store either a value of a given type or nil; this is represented as a union (number | nil), but can be specified using ? as a shorthand syntax (number?). Syntax - Luau