Advertisement
CloneTrooper1019

RbxType

Jul 23rd, 2016
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local function rbxType(this)
  2.     local rawType = type(this)
  3.     if rawType == "userdata" then
  4.         local meta = getmetatable(this)
  5.         if meta == "The metatable is locked" then
  6.             local success,errorMsg = pcall(function ()
  7.                 return workspace:FindPartOnRay(this)
  8.             end)
  9.             if success then
  10.                 return "Ray"
  11.             else
  12.                 local rbxType = errorMsg:sub(16,#errorMsg-7)
  13.                 if rbxType == "token" then
  14.                     return "EnumItem"
  15.                 else
  16.                     local asString = tostring(this)
  17.                     if rbxType == "int" then -- Most likely a BrickColor?
  18.                         if asString == "Medium stone grey" or tostring(BrickColor.new(asString)) ~= "Medium stone grey" then
  19.                             return "BrickColor"
  20.                         else -- ...okay?
  21.                             return rbxType
  22.                         end
  23.                     elseif rbxType == "void" then
  24.                         if this.GetEnumItems then
  25.                             return "Enum"
  26.                         elseif asString == "Connection" then
  27.                             return "RBXScriptConnection"
  28.                         elseif asString:sub(1,6) == "Signal" then
  29.                             return "RBXScriptSignal"
  30.                         elseif asString == "Enums" then
  31.                             return asString
  32.                         elseif this.Help then
  33.                             return "RbxLibrary"
  34.                         else
  35.                             return rbxType
  36.                         end
  37.                     else
  38.                         return rbxType
  39.                     end
  40.                 end
  41.             end
  42.         else -- newproxy?
  43.             return rawType
  44.         end
  45.     else
  46.         return rawType
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement