Extending from Pyro's completely valid answer, here's a script for that.
local igetType do
local TypeIdentities = setmetatable({},{__mode='k'});
local workspace = workspace;
local fpor = workspace.FindPartOnRay;
local fpir3 = workspace.FindPartsInRegion3;
local testComponent = Instance.new("Part");
local testGui = Instance.new("ImageLabel");
local etest = game.ChildAdded.connect;
local junk = function()end;
local Enum = Enum;
local getItems = Enum.KeyCode.GetEnumItems;
local enumTest = function(o) return assert(o == Enum or getItems(o),'') end;
local UDim = UDim;
local assert = assert;
local next = next;
local type = type;
local pcall = pcall;
local game = game;
local pcall = pcall;
local gs = game.GetService;
local function checkud(o)
return UDim.new(0,0) + o
end;
local function set(o,p,i)
o[p] = i;
end
igetType = function(o)
local t = type(o);
if t ~= 'userdata' then return t end;
if pcall(gs, game, o) then
t = "Instance";
elseif pcall(set, testComponent, "Position", o) then
t = "Vector3";
elseif pcall(set, testComponent, "CFrame", o) then
t = "CFrame";
elseif pcall(set, testGui, "BackgroundColor3", o) then
t = "Color3";
elseif pcall(set, testGui, "Size", o) then
t = "UDim2";
elseif pcall(set, testComponent, "BrickColor", o) then
t = "BrickColor";
elseif pcall(etest, o, junk) then
t = "Event";
elseif pcall(enumTest, o) then
t = "Enum";
elseif pcall(function() return assert(type(o.disconnect) == 'function' and o.connected ~= nil,'') end) then
t = "Connection";
elseif pcall(fpor, workspace, o) then
t = "Ray";
elseif pcall(fpir3, workspace, o) then
t = "Region3";
elseif pcall(checkud, o) then
t = "UDim";
elseif pcall(set, testGui, "ImageRectOffset", o) then
t = "Vector2";
end
return t;
end
end
The checking function is now iGetType
Source
2 comments
Thanks
No problem.