EDIT: changed to a feature request:
Calling IsDescendantOf(nil) on any object always returns true instead of throwing an error or returning false if the object is inside the datamodel.
print(workspace.Terrain:IsDescendantOf(nil)) --> true
EDIT: changed to a feature request:
Calling IsDescendantOf(nil) on any object always returns true instead of throwing an error or returning false if the object is inside the datamodel.
print(workspace.Terrain:IsDescendantOf(nil)) --> true
If this is intentional behavior, it’s very unintuitive and stumped me for a good few minutes while debugging my game. It should be changed since its current state serves no purpose and only makes errors in code harder to catch.
Pretty odd, you should dm @Bug-Support since they handle feature requests too
Also mark this as solved pls
For what it’s worth, this is true of a few other APIs too. Ideally the type checker would have caught this.
I’m not sure this was intentional but it is documented so you would need to make a feature request to change it with use cases as to why it’s beneficial, at which point we could get analytics on how many people are using it to see if it’s a low impact change. If that doesn’t prove well, then as @Dekkonot posted, the best we can do is to hope Luau catches this–the code you posted in specific definitely should since we know for sure the left hand side is an instance.
In the meantime, :IsDescendantOf(game)
is the idiom I follow.
Done! The feature request can be found here:
Well it’s partially correct, since Terrain is parented to the game, and the game is parented to nil. But it’s very misleading and it should stop at game
and return false.
-- expected behavior:
workspace.Terrain:IsDescendantOf(nil) --> false
Instance.new("Part"):IsDescendantOf(nil) --> true
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.