Type checking thinks team:GetPlayers() returns Instance instead of Player

Using --!strict:

Warning shown that type is of Instance instead of Player.

Expected behavior

team:GetPlayer() should give me type {Player} (or something to that effect)

4 Likes

Thanks for the report! We’ll follow up when we have an update for you!

1 Like

Hey, sorry for bumping a dead thread, but this is still a thing!


Team:GetPlayers() returns an array of objects of type Instance, when you’d expect them to be Player.

This doesn’t happen in a similar method in game.Players:GetPlayers()

This results in some funky behavior in strict typing where the type checker will complain about one thing but not the other:

1 Like

just as some info, for anyone who wants a workaround, you can explicitely cast to {Player} to get rid of this warning without disabling strict mode.

for _, player in game:GetService("Teams").Team:GetPlayers() :: {Player} do
    print(player.UserId)
end
2 Likes

damn, i’ve been assigning a separate variable like:

local PLEASETHISISAPLAYER = v :: Player
1 Like