CHoff719

Code Exposer -roblox

Jun 4th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.80 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local function ud(x, y)
  4. return UDim2.new(0, x, 0, y)
  5. end
  6.  
  7. local function color(r, g, b)
  8. return Color3.new(r/255, g/255, b/255)
  9. end
  10.  
  11. local function getLines(str)
  12. local count = 0
  13. for parag in string.gmatch(str, "\n") do
  14. count = count + 1
  15. end
  16. return count + 1
  17. end
  18.  
  19. local keys = {
  20. [1] = {w = 0, h = 24},
  21. [2] = {w = 0, h = 24},
  22. [3] = {w = 17, h = 24},
  23. [4] = {w = 17, h = 24},
  24. [5] = {w = 17, h = 24},
  25. [6] = {w = 17, h = 24},
  26. [7] = {w = 17, h = 24},
  27. [8] = {w = 17, h = 24},
  28. [9] = {w = 17, h = 24},
  29. [10] = {w = 17, h = 24},
  30. [11] = {w = 0, h = 48},
  31. [12] = {w = 17, h = 24},
  32. [13] = {w = 17, h = 24},
  33. [14] = {w = 17, h = 24},
  34. [15] = {w = 17, h = 24},
  35. [16] = {w = 17, h = 24},
  36. [17] = {w = 17, h = 24},
  37. [18] = {w = 17, h = 24},
  38. [19] = {w = 17, h = 24},
  39. [20] = {w = 17, h = 24},
  40. [21] = {w = 17, h = 24},
  41. [22] = {w = 17, h = 24},
  42. [23] = {w = 17, h = 24},
  43. [24] = {w = 17, h = 24},
  44. [25] = {w = 17, h = 24},
  45. [26] = {w = 17, h = 24},
  46. [27] = {w = 17, h = 24},
  47. [28] = {w = 17, h = 24},
  48. [29] = {w = 17, h = 24},
  49. [30] = {w = 17, h = 24},
  50. [31] = {w = 17, h = 24},
  51. [32] = {w = 17, h = 24},
  52. [33] = {w = 6, h = 24},
  53. [34] = {w = 6, h = 24},
  54. [35] = {w = 8, h = 24},
  55. [36] = {w = 12, h = 24},
  56. [37] = {w = 12, h = 24},
  57. [38] = {w = 20, h = 24},
  58. [39] = {w = 15, h = 24},
  59. [40] = {w = 4, h = 24},
  60. [41] = {w = 7, h = 24},
  61. [42] = {w = 7, h = 24},
  62. [43] = {w = 9, h = 24},
  63. [44] = {w = 13, h = 24},
  64. [45] = {w = 6, h = 24},
  65. [46] = {w = 7, h = 24},
  66. [47] = {w = 6, h = 24},
  67. [48] = {w = 6, h = 24},
  68. [49] = {w = 12, h = 24},
  69. [50] = {w = 12, h = 24},
  70. [51] = {w = 12, h = 24},
  71. [52] = {w = 12, h = 24},
  72. [53] = {w = 12, h = 24},
  73. [54] = {w = 12, h = 24},
  74. [55] = {w = 12, h = 24},
  75. [56] = {w = 12, h = 24},
  76. [57] = {w = 12, h = 24},
  77. [58] = {w = 12, h = 24},
  78. [59] = {w = 6, h = 24},
  79. [60] = {w = 6, h = 24},
  80. [61] = {w = 13, h = 24},
  81. [62] = {w = 13, h = 24},
  82. [63] = {w = 13, h = 24},
  83. [64] = {w = 12, h = 24},
  84. [65] = {w = 22, h = 24},
  85. [66] = {w = 15, h = 24},
  86. [67] = {w = 15, h = 24},
  87. [68] = {w = 16, h = 24},
  88. [69] = {w = 16, h = 24},
  89. [70] = {w = 15, h = 24},
  90. [71] = {w = 13, h = 24},
  91. [72] = {w = 17, h = 24},
  92. [73] = {w = 16, h = 24},
  93. [74] = {w = 6, h = 24},
  94. [75] = {w = 11, h = 24},
  95. [76] = {w = 15, h = 24},
  96. [77] = {w = 12, h = 24},
  97. [78] = {w = 18, h = 24},
  98. [79] = {w = 16, h = 24},
  99. [80] = {w = 17, h = 24},
  100. [81] = {w = 15, h = 24},
  101. [82] = {w = 17, h = 24},
  102. [83] = {w = 16, h = 24},
  103. [84] = {w = 15, h = 24},
  104. [85] = {w = 13, h = 24},
  105. [86] = {w = 16, h = 24},
  106. [87] = {w = 15, h = 24},
  107. [88] = {w = 21, h = 24},
  108. [89] = {w = 15, h = 24},
  109. [90] = {w = 15, h = 24},
  110. [91] = {w = 13, h = 24},
  111. [92] = {w = 6, h = 24},
  112. [93] = {w = 6, h = 24},
  113. [94] = {w = 6, h = 24},
  114. [95] = {w = 10, h = 24},
  115. [96] = {w = 12, h = 24},
  116. [97] = {w = 7, h = 24},
  117. [98] = {w = 12, h = 24},
  118. [99] = {w = 12, h = 24},
  119. [100] = {w = 11, h = 24},
  120. [101] = {w = 12, h = 24},
  121. [102] = {w = 12, h = 24},
  122. [103] = {w = 6, h = 24},
  123. [104] = {w = 12, h = 24},
  124. [105] = {w = 12, h = 24},
  125. [106] = {w = 5, h = 24},
  126. [107] = {w = 5, h = 24},
  127. [108] = {w = 11, h = 24},
  128. [109] = {w = 5, h = 24},
  129. [110] = {w = 18, h = 24},
  130. [111] = {w = 12, h = 24},
  131. [112] = {w = 12, h = 24},
  132. [113] = {w = 12, h = 24},
  133. [114] = {w = 12, h = 24},
  134. [115] = {w = 7, h = 24},
  135. [116] = {w = 11, h = 24},
  136. [117] = {w = 6, h = 24},
  137. [118] = {w = 12, h = 24},
  138. [119] = {w = 11, h = 24},
  139. [120] = {w = 16, h = 24},
  140. [121] = {w = 11, h = 24},
  141. [122] = {w = 11, h = 24},
  142. [123] = {w = 11, h = 24},
  143. [124] = {w = 7, h = 24},
  144. [125] = {w = 6, h = 24},
  145. [126] = {w = 7, h = 24},
  146. [127] = {w = 13, h = 24},
  147. [128] = {w = 17, h = 24},
  148. }
  149.  
  150.  
  151. local settings = {}
  152. settings.textColor3 = color(0, 0, 0)
  153. settings.TextXAlignment = Enum.TextXAlignment.Left
  154. settings.TextYAlignment = Enum.TextYAlignment.Top
  155. settings.textFont = Enum.Font.Arial
  156. settings.textSize = 24
  157. settings.Background = color(255, 255, 255)
  158. settings.leftBarBackground = color(240, 240, 240)
  159. settings.keyWords = {}
  160. settings.commentColor3 = color(0, 230, 0)
  161. settings.Width = 800
  162. settings.Height = 800
  163.  
  164. settings.keyWords[1] = {
  165. color = color(0, 30, 240),
  166. words = {"local", "function", "return", "nil", "then", "if", "end", "for", "in", "do", "else" , "for", "until", "repeat", "not", "and"}
  167. }
  168.  
  169. settings.keyWords[2] = {
  170. color = color(255, 0, 0),
  171. words = {"true", "false"}
  172. }
  173.  
  174.  
  175. local function newKeyWord(text, size, pos, color, index, parent)
  176. local keyWordLabel = Instance.new("TextLabel")
  177. keyWordLabel.TextXAlignment = settings.TextXAlignment
  178. keyWordLabel.TextYAlignment = settings.TextYAlignment
  179. keyWordLabel.BackgroundTransparency = 1
  180. keyWordLabel.Position = pos
  181. keyWordLabel.Size = ud(20, settings.textSize)
  182. keyWordLabel.Text = text
  183. keyWordLabel.ZIndex = index
  184. keyWordLabel.Font = settings.textFont
  185. keyWordLabel.TextSize = settings.textSize
  186. keyWordLabel.TextColor3 = color
  187. keyWordLabel.Parent = parent
  188. end
  189.  
  190.  
  191. local function getOffset(str, begining, ending)
  192. local posX = 0
  193. local posY = 0
  194. local sizeX = 0
  195. if begining > 1 then
  196. for i = 1, begining - 1 do
  197. local dec = str:sub(i, i):byte()
  198. if dec == 10 then
  199. posY = posY + settings.textSize
  200. posX = 0
  201. else
  202. posX = posX + keys[dec + 1].w
  203. end
  204. end
  205. end
  206. for i = begining, ending do
  207. local dec = str:sub(i, i):byte()
  208. sizeX = sizeX + keys[dec].w
  209. end
  210. return ud(posX, posY),ud(sizeX, settings.textSize)
  211. end
  212.  
  213. local function matchKeyWord(str, keyWord)
  214. local lastWord = 0
  215. local cache = {}
  216. for word in string.gmatch(str, keyWord) do
  217. local begining,ending = str:find("%f[%a]"..word.."%f[%A]", lastWord)
  218. if begining then
  219. cache[#cache + 1] = {text = word, begining = begining, ending = ending}
  220. lastWord = ending + 1
  221. end
  222. end
  223. return cache
  224. end
  225.  
  226. local function display(player, str)
  227. local Character = player.Character
  228. local Root = Character and Character:FindFirstChild("HumanoidRootPart")
  229.  
  230. if Root == nil then
  231. return
  232. end
  233.  
  234. local Luapad = Instance.new("Part")
  235. Luapad.Name = "Luapad"
  236. Luapad.Anchored = true
  237. Luapad.Locked = true
  238. Luapad.TopSurface = Enum.SurfaceType.Smooth
  239. Luapad.BottomSurface = Enum.SurfaceType.Smooth
  240. Luapad.Size = Vector3.new(15, 15, 0.1)
  241. Luapad.CFrame = Root.CFrame *CFrame.new(0, Luapad.Size.Y/2, -5) *CFrame.Angles(0, math.rad(180), 0)
  242. Luapad.Parent = workspace
  243.  
  244. local Surface = Instance.new("SurfaceGui")
  245. Surface.CanvasSize = Vector2.new(settings.Width, settings.Height)
  246. Surface.Parent = Luapad
  247.  
  248. local ScrollingFrame = Instance.new("ScrollingFrame")
  249. ScrollingFrame.BackgroundColor3 = settings.Background
  250. ScrollingFrame.ScrollBarThickness = 24
  251. ScrollingFrame.CanvasSize = ud(0, settings.Height)
  252. ScrollingFrame.Size = ud(settings.Width, settings.Height)
  253. ScrollingFrame.TopImage = "rbxassetid://23043720"
  254. ScrollingFrame.MidImage = "rbxassetid://23043720"
  255. ScrollingFrame.BottomImage = "rbxassetid://23043720"
  256. ScrollingFrame.Parent = Surface
  257.  
  258. local LeftBar = Instance.new("Frame")
  259. LeftBar.Name = "LeftBar"
  260. LeftBar.Size = ud(10, settings.Height)
  261. LeftBar.BackgroundColor3 = settings.leftBarBackground
  262. LeftBar.Parent = ScrollingFrame
  263.  
  264. local Lines = {}
  265. local maxWidthOfBar = 0
  266. local total = getLines(str)
  267.  
  268. for i = 1, total do
  269. local Line = Instance.new("TextLabel")
  270. Line.TextXAlignment = Enum.TextXAlignment.Left
  271. Line.Text = i
  272. Line.TextColor3 = color(0, 0, 0)
  273. Line.Position = ud(0, settings.textSize*(i - 1))
  274. Line.BackgroundTransparency = 1
  275. Line.Font = settings.textFont
  276. Line.TextSize = settings.textSize
  277.  
  278. local width = 0
  279.  
  280. for c = 1, Line.Text:len() do
  281. width = width + keys[Line.Text:sub(c, c):byte() + 1].w
  282. end
  283.  
  284. if width > maxWidthOfBar then
  285. maxWidthOfBar = width
  286. end
  287.  
  288. Line.Size = ud(width, settings.textSize)
  289. Line.Parent = ScrollingFrame
  290. Lines[i] = Line
  291. end
  292.  
  293. for k,v in pairs(Lines) do
  294. v.Size = ud(maxWidthOfBar, settings.textSize)
  295. end
  296.  
  297.  
  298. local Code = Instance.new("TextBox", ScrollingFrame)
  299. Code.Position = ud(LeftBar.Position.X.Offset, 0)
  300. Code.Size = ud(settings.Width, settings.Height)
  301. Code.Name = "Code"
  302. Code.TextXAlignment = settings.TextXAlignment
  303. Code.TextYAlignment = settings.TextYAlignment
  304. Code.BackgroundTransparency = 1
  305. Code.Text = str
  306. Code.Font = settings.textFont
  307. Code.TextSize = settings.textSize
  308. Code.TextColor3 = settings.textColor3
  309.  
  310. local Comments = {}
  311.  
  312. local maxWidth = 0
  313. local offset = ud(maxWidthOfBar + 10, 0)
  314.  
  315.  
  316. for i = 1, #settings.keyWords do
  317. for k,keyWord in pairs(settings.keyWords[i].words) do
  318. local cache = matchKeyWord(str, keyWord)
  319. for c = 1, #cache do
  320. --print(cache[c].begining)
  321. local begining,ending = cache[c].begining, cache[c].ending
  322. local pos,size = getOffset(str, begining, ending)
  323. if size.X.Offset > maxWidth then
  324. maxWidth = size.X.Offset
  325. end
  326. --print(data, data.text, data.size, data.pos)
  327. --print(cache[c].text)
  328. newKeyWord(cache[c].text, size, offset + pos, settings.keyWords[i].color, 4, ScrollingFrame)
  329. end
  330. end
  331. end
  332.  
  333.  
  334. for parag in string.gmatch(str, "[^\n]+") do
  335. --local lastWord = 0
  336. local pos,size = getOffset(parag, 1, parag:len())
  337. if size.X.Offset > maxWidth then
  338. --print(width)
  339. maxWidth = size.X.Offset
  340. end
  341. for comment in string.gmatch(parag, "%-%-[^\"].+") do
  342. local begining,ending = str:find(comment, 1, true)
  343. local pos,size = getOffset(str, begining, ending)
  344. newKeyWord(comment, size, pos + offset, settings.commentColor3, 2, ScrollingFrame)
  345. --lastWord = ending
  346. Comments[#Comments + 1] = {text = comment, begining = begining, ending = ending}
  347. end
  348. end
  349.  
  350. -- this must be fixed later in time.
  351.  
  352. local lastWord = 1
  353. for word in string.gmatch(str, "[=]") do
  354. local b,e = str:find(word, lastWord)
  355. local pos,size = getOffset(str, b, e)
  356. newKeyWord(word, size, pos + offset, color(160, 138, 38), 2, ScrollingFrame)
  357. lastWord = e + 1
  358. end
  359.  
  360.  
  361. pcall(function()
  362. local lastWord = 1
  363. for word in string.gmatch(str, "[\"].-[\"]") do
  364. --print(word)
  365. local b,e = str:find(word, lastWord)
  366. if b then
  367. local pos,size = getOffset(str, b, e)
  368. newKeyWord(word, size, pos + offset, color(0, 255, 0), 3, ScrollingFrame)
  369. lastWord = e + 1
  370. end
  371. end
  372. end)
  373.  
  374.  
  375. pcall(function()
  376. local lastWord = 1
  377. for word in string.gmatch(str, "['].-[']") do
  378. --print(word)
  379. local b,e = str:find(word, lastWord)
  380. if b then
  381. local pos,size = getOffset(str, b, e)
  382. newKeyWord(word, size, pos + offset, color(0, 255, 0), 3, ScrollingFrame)
  383. lastWord = e + 1
  384. end
  385. end
  386. end)
  387.  
  388.  
  389. local maxHeight = 0
  390.  
  391. if total*settings.textSize > maxHeight then
  392. maxHeight = total*settings.textSize
  393. else
  394. maxHeight = settings.Height
  395. end
  396. --print(maxHeight, maxWidth)
  397.  
  398. LeftBar.Size = ud(maxWidthOfBar, maxHeight)
  399. Code.Position = offset
  400. Code.Size = ud(maxWidthOfBar + maxWidth + ScrollingFrame.ScrollBarThickness, maxHeight) + offset
  401. ScrollingFrame.CanvasSize = ud(maxWidthOfBar + maxWidth + ScrollingFrame.ScrollBarThickness, maxHeight) + offset
  402. --print(ScrollingFrame.CanvasSize)
  403.  
  404.  
  405. end
  406.  
  407. local HttpService = game:GetService("HttpService")
  408.  
  409. local function RecieveMessage(player, message)
  410. if not _G[player.Name] then
  411. _G[player.Name] = Settings
  412. end
  413. if message:sub(1, 6) == "!load " then
  414. display(player, message:sub(7), _G[player])
  415. elseif message:sub(1, 5) == "!req " then
  416. local source = nil
  417. local status,err = pcall(function() source = HttpService:GetAsync(message:sub(6)) end)
  418. if source then
  419. display(player, source, _G[player])
  420. else
  421. print(status, err)
  422. end
  423. end
  424. end
  425.  
  426. for k,player in pairs(Players:GetPlayers()) do
  427. player.Chatted:connect(function(message)
  428. RecieveMessage(player, message)
  429. end)
  430. end
  431.  
  432. Players.PlayerAdded:connect(function(player)
  433. player.Chatted:connect(function(message)
  434. RecieveMessage(player, message)
  435. end)
  436. end)
Add Comment
Please, Sign In to add comment