When using typeof() on a Player Instance, returns Instance, not Player

Hello, Everyone.

I am creating an Admin Commands system, which reads a command’s arguments (value types) and converts the arguments inputted by the player into their corresponding values.

Everything is working fine, until I tried to implement a Player value.

args = {"!Player"}, -- Ignore "!", this is automatically removed

When using the typeof() function, which is used to check whether the converted value matches correctly, It returns "Instance", not "Player", which strangely enough, is said to be “Player” in the code hint:
Screenshot 2025-02-26 161252

I’m unsure on what to do. As “userdata” or “Instance” doesn’t roll off the tongue that well and makes for some hacky solutions. I also don’t know whether this is intended behavior or not, so I’d like your input in case it is a bug.

This is the code I used, for clarity:

local service = game:GetService("Players")

service.PlayerAdded:Connect(function(player)
	print(typeof(player))
end)
1 Like

Player is the ClassName of the Instance

print(Player.ClassName) --> Player
print(type(Player)) --> userdata
print(typeof(Player) == "Instance" and Player:IsA("Player")) --> true
3 Likes

Thank you! It appears I’ve confused the two. Not only that, but it’s an added layer of security. I’m not bounded to values anymore.

if typeof(current_arg) == arg_type or typeof(current_arg) == "Instance" and current_arg.ClassName == arg_type then

Sorry for the late response, I had to do a bit of testing.

1 Like