When passing a number, it gets implicitly converted to a string. This is also done by many library functions, and is hard to change because of backwards compatibility. workspace[7]
works the same as workspace:FindFirstChild(7)
, it searches for a child named tostring(7)
(which is probably "7"
, although this isn’t guarnateed).
Some of these functions accept weird values, for instance workspace:FindFirstChild{}
is the same as workspace:FindFirstChild"{}"
I tried passing values of these types: Axes, BrickColor, CatalogSearchParams, Color3, ColorSequence, DateTime, DockWidgetPluginGuiInfo, Enum, Enums, Faces, FloatCurveKey, NumberRange, NumberSequence, NumberSequenceKeypoint, OverlapParams, PathWaypoint, PhysicalProperties, RBXScriptConnection, RBXScriptSignal, Random, Ray, RaycastResult, Rect, Region3, Region3int16, RotationCurveKey, TweenInfo, UDim, UDim2, Vector2, Vector2int16, Vector3int16, CellId, PluginDrag, userdata created by newproxy, and coroutine. They all generated errors when passing them as the second argument to FindFirstChild, e.g. print((pcall(workspace.FindFirstChild,workspace,Vector2.new())))
prints false and workspace:FindFirstChild(Vector2.new())
errors.
It’d be better if passing CFrame, Vector3, RaycastParams, table, function, and boolean values caused errors. These values are likely seldom passed, and if they are passed are then it is probably a bug. There is a substantial amount of code that relies on passing a number (e.g. doing FindFirstChild with an index), making this error would be a breaking change and would be inconsistent with many library functions (e.g. string.rep(1,10)
and math.abs"-1"
both work).