Advertisement
TheRealAK47

Kewl ESP

Dec 8th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.69 KB | None | 0 0
  1. local UserInputService = game:GetService'UserInputService';
  2. local HttpService = game:GetService'HttpService';
  3. local GUIService = game:GetService'GuiService';
  4. local RunService = game:GetService'RunService';
  5. local Players = game:GetService'Players';
  6. local LocalPlayer = Players.LocalPlayer;
  7. local Camera = workspace.CurrentCamera
  8. local Mouse = LocalPlayer:GetMouse();
  9. local Menu = {};
  10. local MouseHeld = false;
  11. local LastRefresh = 0;
  12. local OptionsFile = 'ESP_SETTINGS.dat';
  13. local Binding = false;
  14. local BindedKey = nil;
  15. local OIndex = 0;
  16. local LineBox = {};
  17. local UIButtons = {};
  18. local Sliders = {};
  19. local Dragging = false;
  20. local DraggingUI = false;
  21. local DragOffset = Vector2.new();
  22. local DraggingWhat = nil;
  23. local OldData = {};
  24. local IgnoreList = {};
  25. local Red = Color3.new(0.9, 0, 0);
  26. local Blue = Color3.new(0, 0, 1);
  27. local Pink = Color3.new(1, 0.5, 1);
  28. local MenuLoaded = false;
  29.  
  30. shared.MenuDrawingData = shared.MenuDrawingData or { Instances = {} };
  31. shared.PlayerData = shared.PlayerData or {};
  32. shared.RSName = shared.RSName or ('ESP-' .. HttpService:GenerateGUID(false));
  33.  
  34. local GetDataName = shared.RSName .. '-GetData';
  35. local UpdateName = shared.RSName .. '-Update';
  36.  
  37. local Debounce = setmetatable({}, {
  38. __index = function(t, i)
  39. return rawget(t, i) or false
  40. end;
  41. });
  42.  
  43. pcall(function() shared.InputBeganCon:disconnect() end);
  44. pcall(function() shared.InputEndedCon:disconnect() end);
  45.  
  46. function GetMouseLocation()
  47. return UserInputService:GetMouseLocation();
  48. end
  49.  
  50. function MouseHoveringOver(Values)
  51. local X1, Y1, X2, Y2 = Values[1], Values[2], Values[3], Values[4]
  52. local MLocation = GetMouseLocation();
  53. return (MLocation.x >= X1 and MLocation.x <= (X1 + (X2 - X1))) and (MLocation.y >= Y1 and MLocation.y <= (Y1 + (Y2 - Y1)));
  54. end
  55.  
  56. function GetTableData(t)
  57. if typeof(t) ~= 'table' then return end
  58. return setmetatable(t, {
  59. __call = function(t, func)
  60. if typeof(func) ~= 'function' then return end;
  61. for i, v in pairs(t) do
  62. pcall(func, i, v);
  63. end
  64. end;
  65. });
  66. end
  67. local function Format(format, ...)
  68. return string.format(format, ...);
  69. end
  70. function CalculateValue(Min, Max, Percent)
  71. return Min + math.floor(((Max - Min) * Percent) + .5);
  72. end
  73.  
  74. local Options = setmetatable({}, {
  75. __call = function(t, ...)
  76. local Arguments = {...};
  77. local Name = Arguments[1];
  78. OIndex = OIndex + 1;
  79. rawset(t, Name, setmetatable({
  80. Name = Arguments[1];
  81. Text = Arguments[2];
  82. Value = Arguments[3];
  83. DefaultValue = Arguments[3];
  84. AllArgs = Arguments;
  85. Index = OIndex;
  86. }, {
  87. __call = function(t, v)
  88. if typeof(t.Value) == 'function' then
  89. t.Value();
  90. elseif typeof(t.Value) == 'EnumItem' then
  91. local BT = Menu:GetInstance(Format('%s_BindText', t.Name));
  92. Binding = true;
  93. local Val = 0
  94. while Binding do
  95. wait();
  96. Val = (Val + 1) % 17;
  97. BT.Text = Val <= 8 and '|' or '';
  98. end
  99. t.Value = BindedKey;
  100. BT.Text = tostring(t.Value):match'%w+%.%w+%.(.+)';
  101. BT.Position = t.BasePosition + Vector2.new(t.BaseSize.X - BT.TextBounds.X - 20, -10);
  102. else
  103. local NewValue = v;
  104. if NewValue == nil then NewValue = not t.Value; end
  105. rawset(t, 'Value', NewValue);
  106. if Arguments[2] ~= nil then
  107. if typeof(Arguments[3]) == 'number' then
  108. local AMT = Menu:GetInstance(Format('%s_AmountText', t.Name));
  109. AMT.Text = tostring(t.Value);
  110. AMT.Position = t.BasePosition + Vector2.new(t.BaseSize.X - AMT.TextBounds.X - 10, -10);
  111. else
  112. local Inner = Menu:GetInstance(Format('%s_InnerCircle', t.Name));
  113. Inner.Visible = t.Value;
  114. end
  115. end
  116. end
  117. end;
  118. }));
  119. end;
  120. })
  121.  
  122. function Load()
  123. local _, Result = pcall(readfile, OptionsFile);
  124. if _ then
  125. local _, Table = pcall(HttpService.JSONDecode, HttpService, Result);
  126. if _ then
  127. for i, v in pairs(Table) do
  128. if Options[i] ~= nil and Options[i].Value ~= nil and (typeof(Options[i].Value) == 'boolean' or typeof(Options[i].Value) == 'number') then
  129. Options[i].Value = v.Value;
  130. pcall(Options[i], v.Value);
  131. end
  132. end
  133. end
  134. end
  135. end
  136.  
  137. Options('Enabled', 'ESP Enabled', true);
  138. Options('ShowTeam', 'Show Team', false);
  139. Options('ShowName', 'Show Names', true);
  140. Options('ShowDistance', 'Show Distance', true);
  141. Options('ShowHealth', 'Show Health', true);
  142. Options('ShowBoxes', 'Show Boxes', true);
  143. Options('ShowTracers', 'Show Tracers', true);
  144. Options('ShowDot', 'Show Head Dot', false);
  145. Options('VisCheck', 'Visibility Check', false);
  146. Options('Crosshair', 'Crosshair', false);
  147. Options('TextOutline', 'Text Outline', true);
  148. Options('TextSize', 'Text Size', syn and 18 or 14, 10, 24);
  149. Options('MaxDistance', 'Max Distance', 2500, 100, 500000000);
  150. Options('RefreshRate', 'Refresh Rate (ms)', 5, 1, 200);
  151. Options('MenuKey', 'Menu Key', Enum.KeyCode.F4, 1);
  152. Options('ResetSettings', 'Reset Settings', function()
  153. for i, v in pairs(Options) do
  154. if Options[i] ~= nil and Options[i].Value ~= nil and Options[i].Text ~= nil and (typeof(Options[i].Value) == 'boolean' or typeof(Options[i].Value) == 'number') then
  155. Options[i](Options[i].DefaultValue);
  156. end
  157. end
  158. end, 4);
  159. Options('LoadSettings', 'Load Settings', Load, 3);
  160. Options('SaveSettings', 'Save Settings', function()
  161. writefile(OptionsFile, HttpService:JSONEncode(Options));
  162. end, 2)
  163.  
  164. Load();
  165.  
  166. Options('MenuOpen', nil, true);
  167.  
  168. local function Set(t, i, v)
  169. t[i] = v;
  170. end
  171. local function Combine(...)
  172. local Output = {};
  173. for i, v in pairs{...} do
  174. if typeof(v) == 'table' then
  175. table.foreach(v, function(i, v)
  176. Output[i] = v;
  177. end)
  178. end
  179. end
  180. return Output
  181. end
  182. function IsStringEmpty(String)
  183. if type(String) == 'string' then
  184. return String:match'^%s+$' ~= nil or #String == 0 or String == '' or false;
  185. end
  186. return false
  187. end
  188.  
  189. function NewDrawing(InstanceName)
  190. local Instance = Drawing.new(InstanceName);
  191. return (function(Properties)
  192. for i, v in pairs(Properties) do
  193. pcall(Set, Instance, i, v);
  194. end
  195. return Instance;
  196. end)
  197. end
  198.  
  199. function Menu:AddMenuInstace(Name, Instance)
  200. if shared.MenuDrawingData.Instances[Name] ~= nil then
  201. shared.MenuDrawingData.Instances[Name]:Remove();
  202. end
  203. shared.MenuDrawingData.Instances[Name] = Instance;
  204. return Instance;
  205. end
  206. function Menu:UpdateMenuInstance(Name)
  207. local Instance = shared.MenuDrawingData.Instances[Name];
  208. if Instance ~= nil then
  209. return (function(Properties)
  210. for i, v in pairs(Properties) do
  211. pcall(Set, Instance, i, v);
  212. end
  213. return Instance;
  214. end)
  215. end
  216. end
  217. function Menu:GetInstance(Name)
  218. return shared.MenuDrawingData.Instances[Name];
  219. end
  220.  
  221. function LineBox:Create(Properties)
  222. local Box = { Visible = true };
  223.  
  224. local Properties = Combine({
  225. Transparency = 0.75;
  226. Thickness = 1;
  227. Visible = true;
  228. }, Properties);
  229.  
  230. Box['TopLeft'] = NewDrawing'Line'(Properties);
  231. Box['TopRight'] = NewDrawing'Line'(Properties);
  232. Box['BottomLeft'] = NewDrawing'Line'(Properties);
  233. Box['BottomRight'] = NewDrawing'Line'(Properties);
  234.  
  235. function Box:Update(CF, Size, Color, Properties)
  236. if not CF or not Size then return end
  237.  
  238. local TLPos, Visible1 = Camera:WorldToViewportPoint((CF * CFrame.new( Size.X, Size.Y, 0)).p);
  239. local TRPos, Visible2 = Camera:WorldToViewportPoint((CF * CFrame.new(-Size.X, Size.Y, 0)).p);
  240. local BLPos, Visible3 = Camera:WorldToViewportPoint((CF * CFrame.new( Size.X, -Size.Y, 0)).p);
  241. local BRPos, Visible4 = Camera:WorldToViewportPoint((CF * CFrame.new(-Size.X, -Size.Y, 0)).p);
  242. if Visible1 then
  243. Box['TopLeft'].Visible = true;
  244. Box['TopLeft'].Color = Color;
  245. Box['TopLeft'].From = Vector2.new(TLPos.X, TLPos.Y);
  246. Box['TopLeft'].To = Vector2.new(TRPos.X, TRPos.Y);
  247. else
  248. Box['TopLeft'].Visible = false;
  249. end
  250. if Visible2 then
  251. Box['TopRight'].Visible = true;
  252. Box['TopRight'].Color = Color;
  253. Box['TopRight'].From = Vector2.new(TRPos.X, TRPos.Y);
  254. Box['TopRight'].To = Vector2.new(BRPos.X, BRPos.Y);
  255. else
  256. Box['TopRight'].Visible = false;
  257. end
  258. if Visible3 then
  259. Box['BottomLeft'].Visible = true;
  260. Box['BottomLeft'].Color = Color;
  261. Box['BottomLeft'].From = Vector2.new(BLPos.X, BLPos.Y);
  262. Box['BottomLeft'].To = Vector2.new(TLPos.X, TLPos.Y);
  263. else
  264. Box['BottomLeft'].Visible = false;
  265. end
  266. if Visible4 then
  267. Box['BottomRight'].Visible = true;
  268. Box['BottomRight'].Color = Color;
  269. Box['BottomRight'].From = Vector2.new(BRPos.X, BRPos.Y);
  270. Box['BottomRight'].To = Vector2.new(BLPos.X, BLPos.Y);
  271. else
  272. Box['BottomRight'].Visible = false;
  273. end
  274. if Properties then
  275. GetTableData(Properties)(function(i, v)
  276. pcall(Set, Box['TopLeft'], i, v);
  277. pcall(Set, Box['TopRight'], i, v);
  278. pcall(Set, Box['BottomLeft'], i, v);
  279. pcall(Set, Box['BottomRight'], i, v);
  280. end)
  281. end
  282. end
  283. function Box:SetVisible(bool)
  284. pcall(Set, Box['TopLeft'], 'Visible', bool);
  285. pcall(Set, Box['TopRight'], 'Visible', bool);
  286. pcall(Set, Box['BottomLeft'], 'Visible', bool);
  287. pcall(Set, Box['BottomRight'], 'Visible', bool);
  288. end
  289. function Box:Remove()
  290. self:SetVisible(false);
  291. Box['TopLeft']:Remove();
  292. Box['TopRight']:Remove();
  293. Box['BottomLeft']:Remove();
  294. Box['BottomRight']:Remove();
  295. end
  296.  
  297. return Box;
  298. end
  299.  
  300. function CreateMenu(NewPosition)
  301. local function FromHex(HEX)
  302. HEX = HEX:gsub('#', '');
  303. return Color3.fromRGB(tonumber('0x' .. HEX:sub(1, 2)), tonumber('0x' .. HEX:sub(3, 4)), tonumber('0x' .. HEX:sub(5, 6)));
  304. end
  305.  
  306. local Colors = {
  307. Primary = {
  308. Main = FromHex'424242';
  309. Light = FromHex'6d6d6d';
  310. Dark = FromHex'1b1b1b';
  311. };
  312. Secondary = {
  313. Main = FromHex'e0e0e0';
  314. Light = FromHex'ffffff';
  315. Dark = FromHex'aeaeae';
  316. };
  317. };
  318.  
  319. MenuLoaded = false;
  320.  
  321. GetTableData(UIButtons)(function(i, v)
  322. v.Instance.Visible = false;
  323. v.Instance:Remove();
  324. end)
  325. GetTableData(Sliders)(function(i, v)
  326. v.Instance.Visible = false;
  327. v.Instance:Remove();
  328. end)
  329.  
  330. UIButtons = {};
  331. Sliders = {};
  332.  
  333. local BaseSize = Vector2.new(300, 580);
  334. local BasePosition = NewPosition or Vector2.new(Camera.ViewportSize.X / 8 - (BaseSize.X / 2), Camera.ViewportSize.Y / 2 - (BaseSize.Y / 2));
  335.  
  336. Menu:AddMenuInstace('CrosshairX', NewDrawing'Line'{
  337. Visible = false;
  338. Color = Color3.new(0, 1, 0);
  339. Transparency = .5;
  340. Thickness = 1;
  341. });
  342. Menu:AddMenuInstace('CrosshairY', NewDrawing'Line'{
  343. Visible = false;
  344. Color = Color3.new(1, 0, 0);
  345. Transparency = .5;
  346. Thickness = 1;
  347. });
  348.  
  349. delay(0, function()
  350. Menu:AddMenuInstace('Main', NewDrawing'Square'{
  351. Size = BaseSize;
  352. Position = BasePosition;
  353. Filled = false;
  354. Color = Colors.Primary.Main;
  355. Thickness = 3;
  356. Visible = true;
  357. });
  358. end);
  359. Menu:AddMenuInstace('TopBar', NewDrawing'Square'{
  360. Position = BasePosition;
  361. Size = Vector2.new(BaseSize.X, 25);
  362. Color = Colors.Primary.Dark;
  363. Filled = true;
  364. Visible = true;
  365. });
  366. Menu:AddMenuInstace('TopBarTwo', NewDrawing'Square'{
  367. Position = BasePosition + Vector2.new(0, 25);
  368. Size = Vector2.new(BaseSize.X, 60);
  369. Color = Colors.Primary.Main;
  370. Filled = true;
  371. Visible = true;
  372. });
  373. Menu:AddMenuInstace('TopBarText', NewDrawing'Text'{
  374. Size = 25;
  375. Position = shared.MenuDrawingData.Instances.TopBarTwo.Position + Vector2.new(25, 15);
  376. Text = 'Kewl ESP';
  377. Color = Colors.Secondary.Light;
  378. Visible = true;
  379. });
  380. Menu:AddMenuInstace('TopBarTextBR', NewDrawing'Text'{
  381. Size = 15;
  382. Position = shared.MenuDrawingData.Instances.TopBarTwo.Position + Vector2.new(BaseSize.X - 65, 40);
  383. Text = 'ESP';
  384. Color = Colors.Secondary.Dark;
  385. Visible = true;
  386. });
  387. Menu:AddMenuInstace('Filling', NewDrawing'Square'{
  388. Size = BaseSize - Vector2.new(0, 85);
  389. Position = BasePosition + Vector2.new(0, 85);
  390. Filled = true;
  391. Color = Colors.Secondary.Main;
  392. Transparency= .5;
  393. Visible = true;
  394. });
  395.  
  396. local CPos = 0;
  397.  
  398. GetTableData(Options)(function(i, v)
  399. if typeof(v.Value) == 'boolean' and not IsStringEmpty(v.Text) and v.Text ~= nil then
  400. CPos = CPos + 25;
  401. local BaseSize = Vector2.new(BaseSize.X, 30);
  402. local BasePosition = shared.MenuDrawingData.Instances.Filling.Position + Vector2.new(30, v.Index * 25 - 10);
  403. UIButtons[#UIButtons + 1] = {
  404. Option = v;
  405. Instance = Menu:AddMenuInstace(Format('%s_Hitbox', v.Name), NewDrawing'Square'{
  406. Position = BasePosition - Vector2.new(30, 15);
  407. Size = BaseSize;
  408. Visible = false;
  409. });
  410. };
  411. Menu:AddMenuInstace(Format('%s_OuterCircle', v.Name), NewDrawing'Circle'{
  412. Radius = 10;
  413. Position = BasePosition;
  414. Color = Colors.Secondary.Light;
  415. Filled = true;
  416. Visible = true;
  417. });
  418. Menu:AddMenuInstace(Format('%s_InnerCircle', v.Name), NewDrawing'Circle'{
  419. Radius = 7;
  420. Position = BasePosition;
  421. Color = Colors.Secondary.Dark;
  422. Filled = true;
  423. Visible = v.Value;
  424. });
  425. Menu:AddMenuInstace(Format('%s_Text', v.Name), NewDrawing'Text'{
  426. Text = v.Text;
  427. Size = 20;
  428. Position = BasePosition + Vector2.new(20, -10);
  429. Visible = true;
  430. Color = Colors.Primary.Dark;
  431. });
  432. end
  433. end)
  434. GetTableData(Options)(function(i, v)
  435. if typeof(v.Value) == 'number' then
  436. CPos = CPos + 25;
  437.  
  438. local BaseSize = Vector2.new(BaseSize.X, 30);
  439. local BasePosition = shared.MenuDrawingData.Instances.Filling.Position + Vector2.new(0, CPos - 10);
  440.  
  441. local Text = Menu:AddMenuInstace(Format('%s_Text', v.Name), NewDrawing'Text'{
  442. Text = v.Text;
  443. Size = 20;
  444. Position = BasePosition + Vector2.new(20, -10);
  445. Visible = true;
  446. Color = Colors.Primary.Dark;
  447. });
  448. local AMT = Menu:AddMenuInstace(Format('%s_AmountText', v.Name), NewDrawing'Text'{
  449. Text = tostring(v.Value);
  450. Size = 20;
  451. Position = BasePosition;
  452. Visible = true;
  453. Color = Colors.Primary.Dark;
  454. });
  455. local Line = Menu:AddMenuInstace(Format('%s_SliderLine', v.Name), NewDrawing'Line'{
  456. Transparency = .5;
  457. Color = Colors.Primary.Dark;
  458. Thickness = 3;
  459. Visible = true;
  460. From = BasePosition + Vector2.new(20, 20);
  461. To = BasePosition + Vector2.new(BaseSize.X - 10, 20);
  462. });
  463. CPos = CPos + 10;
  464. local Slider = Menu:AddMenuInstace(Format('%s_Slider', v.Name), NewDrawing'Circle'{
  465. Visible = true;
  466. Filled = true;
  467. Radius = 6;
  468. Color = Colors.Secondary.Dark;
  469. Position = BasePosition + Vector2.new(35, 20);
  470. })
  471.  
  472. local CSlider = {Slider = Slider; Line = Line; Min = v.AllArgs[4]; Max = v.AllArgs[5]; Option = v};
  473. Sliders[#Sliders + 1] = CSlider;
  474.  
  475. Slider.Position = BasePosition + Vector2.new(40, 20);
  476.  
  477. v.BaseSize = BaseSize;
  478. v.BasePosition = BasePosition;
  479. AMT.Position = BasePosition + Vector2.new(BaseSize.X - AMT.TextBounds.X - 10, -10)
  480. end
  481. end)
  482. GetTableData(Options)(function(i, v)
  483. if typeof(v.Value) == 'EnumItem' then
  484. CPos = CPos + 30;
  485.  
  486. local BaseSize = Vector2.new(BaseSize.X, 30);
  487. local BasePosition = shared.MenuDrawingData.Instances.Filling.Position + Vector2.new(0, CPos - 10);
  488.  
  489. UIButtons[#UIButtons + 1] = {
  490. Option = v;
  491. Instance = Menu:AddMenuInstace(Format('%s_Hitbox', v.Name), NewDrawing'Square'{
  492. Size = Vector2.new(BaseSize.X, 20) - Vector2.new(30, 0);
  493. Visible = true;
  494. Transparency= .5;
  495. Position = BasePosition + Vector2.new(15, -10);
  496. Color = Colors.Secondary.Light;
  497. Filled = true;
  498. });
  499. };
  500. local Text = Menu:AddMenuInstace(Format('%s_Text', v.Name), NewDrawing'Text'{
  501. Text = v.Text;
  502. Size = 20;
  503. Position = BasePosition + Vector2.new(20, -10);
  504. Visible = true;
  505. Color = Colors.Primary.Dark;
  506. });
  507. local BindText = Menu:AddMenuInstace(Format('%s_BindText', v.Name), NewDrawing'Text'{
  508. Text = tostring(v.Value):match'%w+%.%w+%.(.+)';
  509. Size = 20;
  510. Position = BasePosition;
  511. Visible = true;
  512. Color = Colors.Primary.Dark;
  513. });
  514.  
  515. Options[i].BaseSize = BaseSize;
  516. Options[i].BasePosition = BasePosition;
  517. BindText.Position = BasePosition + Vector2.new(BaseSize.X - BindText.TextBounds.X - 20, -10);
  518. end
  519. end)
  520. GetTableData(Options)(function(i, v)
  521. if typeof(v.Value) == 'function' then
  522. local BaseSize = Vector2.new(BaseSize.X, 30);
  523. local BasePosition = shared.MenuDrawingData.Instances.Filling.Position + Vector2.new(0, CPos + (25 * v.AllArgs[4]) - 35);
  524.  
  525. UIButtons[#UIButtons + 1] = {
  526. Option = v;
  527. Instance = Menu:AddMenuInstace(Format('%s_Hitbox', v.Name), NewDrawing'Square'{
  528. Size = Vector2.new(BaseSize.X, 20) - Vector2.new(30, 0);
  529. Visible = true;
  530. Transparency= .5;
  531. Position = BasePosition + Vector2.new(15, -10);
  532. Color = Colors.Secondary.Light;
  533. Filled = true;
  534. });
  535. };
  536. local Text = Menu:AddMenuInstace(Format('%s_Text', v.Name), NewDrawing'Text'{
  537. Text = v.Text;
  538. Size = 20;
  539. Position = BasePosition + Vector2.new(20, -10);
  540. Visible = true;
  541. Color = Colors.Primary.Dark;
  542. });
  543. end
  544. end)
  545.  
  546. delay(0, function()
  547. MenuLoaded = true;
  548. end);
  549.  
  550. Menu:AddMenuInstace('Cursor1', NewDrawing'Line'{
  551. Visible = false;
  552. Color = Color3.new(1, 0, 0);
  553. Transparency = 1;
  554. Thickness = 2;
  555. });
  556. Menu:AddMenuInstace('Cursor2', NewDrawing'Line'{
  557. Visible = false;
  558. Color = Color3.new(1, 0, 0);
  559. Transparency = 1;
  560. Thickness = 2;
  561. });
  562. Menu:AddMenuInstace('Cursor3', NewDrawing'Line'{
  563. Visible = false;
  564. Color = Color3.new(1, 0, 0);
  565. Transparency = 1;
  566. Thickness = 2;
  567. });
  568. end
  569.  
  570. CreateMenu();
  571.  
  572. shared.InputBeganCon = UserInputService.InputBegan:connect(function(input)
  573. if input.UserInputType.Name == 'MouseButton1' and Options.MenuOpen.Value then
  574. MouseHeld = true;
  575. local Bar = Menu:GetInstance'TopBar';
  576. local Values = {
  577. Bar.Position.X;
  578. Bar.Position.Y;
  579. Bar.Position.X + Bar.Size.X;
  580. Bar.Position.Y + Bar.Size.Y;
  581. }
  582. if MouseHoveringOver(Values) and not syn then -- disable dragging for synapse cuz idk why it breaks
  583. DraggingUI = true;
  584. DragOffset = Menu:GetInstance'Main'.Position - GetMouseLocation();
  585. else
  586. for i, v in pairs(Sliders) do
  587. local Values = {
  588. v.Line.From.X - (v.Slider.Radius);
  589. v.Line.From.Y - (v.Slider.Radius);
  590. v.Line.To.X + (v.Slider.Radius);
  591. v.Line.To.Y + (v.Slider.Radius);
  592. };
  593. if MouseHoveringOver(Values) then
  594. DraggingWhat = v;
  595. Dragging = true;
  596. break
  597. end
  598. end
  599. end
  600. end
  601. end)
  602. shared.InputEndedCon = UserInputService.InputEnded:connect(function(input)
  603. if input.UserInputType.Name == 'MouseButton1' and Options.MenuOpen.Value then
  604. MouseHeld = false;
  605. for i, v in pairs(UIButtons) do
  606. local Values = {
  607. v.Instance.Position.X;
  608. v.Instance.Position.Y;
  609. v.Instance.Position.X + v.Instance.Size.X;
  610. v.Instance.Position.Y + v.Instance.Size.Y;
  611. };
  612. if MouseHoveringOver(Values) then
  613. v.Option();
  614. break
  615. end
  616. end
  617. elseif input.UserInputType.Name == 'Keyboard' then
  618. if Binding then
  619. BindedKey = input.KeyCode;
  620. Binding = false;
  621. elseif input.KeyCode == Options.MenuKey.Value or (input.KeyCode == Enum.KeyCode.Home and UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)) then
  622. Options.MenuOpen();
  623. end
  624. end
  625. end)
  626.  
  627. function ToggleMenu()
  628. if Options.MenuOpen.Value then
  629. GetTableData(shared.MenuDrawingData.Instances)(function(i, v)
  630. if OldData[v] then
  631. pcall(Set, v, 'Visible', true);
  632. end
  633. end)
  634. else
  635. GetTableData(shared.MenuDrawingData.Instances)(function(i, v)
  636. if v.Visible == true then
  637. OldData[v] = true;
  638. pcall(Set, v, 'Visible', false);
  639. end
  640. end)
  641. end
  642. end
  643.  
  644. function CheckRay(Player, Distance, Position, Unit)
  645. local Pass = true;
  646.  
  647. if Distance > 999 then return false; end
  648.  
  649. local _Ray = Ray.new(Position, Unit * Distance);
  650.  
  651. local List = {LocalPlayer.Character, Camera, Mouse.TargetFilter};
  652.  
  653. for i,v in pairs(IgnoreList) do table.insert(List, v); end;
  654.  
  655. local Hit = workspace:FindPartOnRayWithIgnoreList(_Ray, List);
  656. if Hit and not Hit:IsDescendantOf(Player.Character) then
  657. Pass = false;
  658. if Hit.Transparency >= .3 or not Hit.CanCollide and Hit.ClassName ~= Terrain then -- Detect invisible walls
  659. IgnoreList[#IgnoreList + 1] = Hit;
  660. end
  661. end
  662.  
  663. return Pass;
  664. end
  665.  
  666. function CheckPlayer(Player)
  667. if not Options.Enabled.Value then return false end
  668.  
  669. local Pass = true;
  670. local Distance = 0;
  671.  
  672. if Player ~= LocalPlayer and Player.Character then
  673. if not Options.ShowTeam.Value and Player.TeamColor == LocalPlayer.TeamColor then
  674. Pass = false;
  675. end
  676.  
  677. local Head = Player.Character:FindFirstChild'Head';
  678.  
  679. if Pass and Player.Character and Head then
  680. Distance = (Camera.CFrame.p - Head.Position).magnitude;
  681. if Options.VisCheck.Value then
  682. Pass = CheckRay(Player, Distance, Camera.CFrame.p, (Head.Position - Camera.CFrame.p).unit);
  683. end
  684. if Distance > Options.MaxDistance.Value then
  685. Pass = false;
  686. end
  687. end
  688. else
  689. Pass = false;
  690. end
  691.  
  692. return Pass, Distance;
  693. end
  694.  
  695. function UpdatePlayerData()
  696. if (tick() - LastRefresh) > (Options.RefreshRate.Value / 1000) then
  697. LastRefresh = tick();
  698. for i, v in pairs(Players:GetPlayers()) do
  699. local Data = shared.PlayerData[v.Name] or { Instances = {} };
  700.  
  701. Data.Instances['Box'] = Data.Instances['Box'] or LineBox:Create{Thickness = 3};
  702. Data.Instances['Tracer'] = Data.Instances['Tracer'] or NewDrawing'Line'{
  703. Transparency = .5;
  704. Thickness = 2;
  705. }
  706. Data.Instances['HeadDot'] = Data.Instances['HeadDot'] or NewDrawing'Circle'{
  707. Filled = false;
  708. NumSides = 50;
  709. Thickness = 2.5;
  710. }
  711. Data.Instances['NameTag'] = Data.Instances['NameTag'] or NewDrawing'Text'{
  712. Size = Options.TextSize.Value;
  713. Center = true;
  714. Outline = Options.TextOutline.Value;
  715. Transparency = .75;
  716. Visible = true;
  717. };
  718. Data.Instances['DistanceHealthTag'] = Data.Instances['DistanceHealthTag'] or NewDrawing'Text'{
  719. Size = Options.TextSize.Value - 1;
  720. Center = true;
  721. Outline = Options.TextOutline.Value;
  722. Visible = true;
  723. };
  724.  
  725. local NameTag = Data.Instances['NameTag'];
  726. local DistanceTag = Data.Instances['DistanceHealthTag'];
  727. local Tracer = Data.Instances['Tracer'];
  728. local HeadDot = Data.Instances['HeadDot'];
  729. local Box = Data.Instances['Box'];
  730.  
  731. local Pass, Distance = CheckPlayer(v);
  732.  
  733. if Pass and v.Character then
  734. Data.LastUpdate = tick();
  735. local Humanoid = v.Character:FindFirstChildOfClass'Humanoid';
  736. local Head = v.Character:FindFirstChild'Head';
  737. local HumanoidRootPart = v.Character:FindFirstChild'HumanoidRootPart';
  738. if v.Character ~= nil and Head then
  739. local ScreenPosition, Vis = Camera:WorldToViewportPoint(Head.Position);
  740. if Vis then
  741. local Color = v.TeamColor == LocalPlayer.TeamColor and Blue or Pink;
  742.  
  743. local ScreenPositionUpper = Camera:WorldToViewportPoint(Head.CFrame * CFrame.new(0, Head.Size.Y, 0).p);
  744. local Scale = Head.Size.Y / 2;
  745.  
  746. if Options.ShowName.Value then
  747. NameTag.Visible = true;
  748. NameTag.Text = v.Name;
  749. NameTag.Size = Options.TextSize.Value;
  750. NameTag.Outline = Options.TextOutline.Value;
  751. NameTag.Position = Vector2.new(ScreenPositionUpper.X, ScreenPositionUpper.Y);
  752. NameTag.Color = Color;
  753. if Drawing.Fonts then
  754. NameTag.Font = Drawing.Fonts.UI;
  755. end
  756. else
  757. NameTag.Visible = false;
  758. end
  759. if Options.ShowDistance.Value or Options.ShowHealth.Value then
  760. DistanceTag.Visible = true;
  761. DistanceTag.Size = Options.TextSize.Value - 1;
  762. DistanceTag.Outline = Options.TextOutline.Value;
  763. DistanceTag.Color = Color3.new(0, 1, 0);
  764. if Drawing.Fonts then
  765. NameTag.Font = Drawing.Fonts.UI;
  766. end
  767.  
  768. local Str = '';
  769.  
  770. if Options.ShowDistance.Value then
  771. Str = Str .. Format('[%d] ', Distance);
  772. end
  773. if Options.ShowHealth.Value and Humanoid then
  774. Str = Str .. Format('[%d/100]', Humanoid.Health / Humanoid.MaxHealth * 100);
  775. end
  776.  
  777. DistanceTag.Text = Str;
  778. DistanceTag.Position = Vector2.new(ScreenPositionUpper.X, ScreenPositionUpper.Y) + Vector2.new(0, NameTag.Size);
  779. else
  780. DistanceTag.Visible = false;
  781. end
  782. if Options.ShowDot.Value then
  783. local Top = Camera:WorldToViewportPoint((Head.CFrame * CFrame.new(0, Scale, 0)).p);
  784. local Bottom = Camera:WorldToViewportPoint((Head.CFrame * CFrame.new(0, -Scale, 0)).p);
  785. local Radius = (Top - Bottom).y;
  786.  
  787. HeadDot.Visible = true;
  788. HeadDot.Color = Color;
  789. HeadDot.Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y);
  790. HeadDot.Radius = Radius;
  791. else
  792. HeadDot.Visible = false;
  793. end
  794. if Options.ShowTracers.Value then
  795. Tracer.Visible = true;
  796. Tracer.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y);
  797. Tracer.To = Vector2.new(ScreenPosition.X, ScreenPosition.Y);
  798. Tracer.Color = Color;
  799. else
  800. Tracer.Visible = false;
  801. end
  802. if Options.ShowBoxes.Value and HumanoidRootPart then
  803. Box:Update(HumanoidRootPart.CFrame, Vector3.new(2, 3, 0) * (Scale * 2), Color);
  804. else
  805. Box:SetVisible(false);
  806. end
  807. else
  808. NameTag.Visible = false;
  809. DistanceTag.Visible = false;
  810. Tracer.Visible = false;
  811. HeadDot.Visible = false;
  812.  
  813. Box:SetVisible(false);
  814. end
  815. end
  816. else
  817. NameTag.Visible = false;
  818. DistanceTag.Visible = false;
  819. Tracer.Visible = false;
  820. HeadDot.Visible = false;
  821.  
  822. Box:SetVisible(false);
  823. end
  824.  
  825. shared.PlayerData[v.Name] = Data;
  826. end
  827. end
  828. end
  829.  
  830. function Update()
  831. for i, v in pairs(shared.PlayerData) do
  832. if not Players:FindFirstChild(tostring(i)) then
  833. GetTableData(v.Instances)(function(i, obj)
  834. obj.Visible = false;
  835. obj:Remove();
  836. v.Instances[i] = nil;
  837. end)
  838. shared.PlayerData[i] = nil;
  839. end
  840. end
  841.  
  842. local CX = Menu:GetInstance'CrosshairX';
  843. local CY = Menu:GetInstance'CrosshairY';
  844. if Options.Crosshair.Value then
  845. CX.Visible = true;
  846. CY.Visible = true;
  847.  
  848. CX.To = Vector2.new((Camera.ViewportSize.X / 2) - 8, (Camera.ViewportSize.Y / 2));
  849. CX.From = Vector2.new((Camera.ViewportSize.X / 2) + 8, (Camera.ViewportSize.Y / 2));
  850. CY.To = Vector2.new((Camera.ViewportSize.X / 2), (Camera.ViewportSize.Y / 2) - 8);
  851. CY.From = Vector2.new((Camera.ViewportSize.X / 2), (Camera.ViewportSize.Y / 2) + 8);
  852. else
  853. CX.Visible = false;
  854. CY.Visible = false;
  855. end
  856.  
  857. if Options.MenuOpen.Value and MenuLoaded then
  858. local MLocation = GetMouseLocation();
  859. shared.MenuDrawingData.Instances.Main.Color = Color3.fromHSV(tick() * 24 % 255/255, 1, 1);
  860. local MainInstance = Menu:GetInstance'Main';
  861. local Values = {
  862. MainInstance.Position.X;
  863. MainInstance.Position.Y;
  864. MainInstance.Position.X + MainInstance.Size.X;
  865. MainInstance.Position.Y + MainInstance.Size.Y;
  866. };
  867. if MainInstance and MouseHoveringOver(Values) then
  868. Debounce.CursorVis = true;
  869. Menu:UpdateMenuInstance'Cursor1'{
  870. Visible = true;
  871. From = Vector2.new(MLocation.x, MLocation.y);
  872. To = Vector2.new(MLocation.x + 5, MLocation.y + 6);
  873. }
  874. Menu:UpdateMenuInstance'Cursor2'{
  875. Visible = true;
  876. From = Vector2.new(MLocation.x, MLocation.y);
  877. To = Vector2.new(MLocation.x, MLocation.y + 8);
  878. }
  879. Menu:UpdateMenuInstance'Cursor3'{
  880. Visible = true;
  881. From = Vector2.new(MLocation.x, MLocation.y + 6);
  882. To = Vector2.new(MLocation.x + 5, MLocation.y + 5);
  883. }
  884. else
  885. if Debounce.CursorVis then
  886. Debounce.CursorVis = false;
  887. Menu:UpdateMenuInstance'Cursor1'{Visible = false};
  888. Menu:UpdateMenuInstance'Cursor2'{Visible = false};
  889. Menu:UpdateMenuInstance'Cursor3'{Visible = false};
  890. end
  891. end
  892. if MouseHeld then
  893. if Dragging then
  894. DraggingWhat.Slider.Position = Vector2.new(math.clamp(MLocation.X, DraggingWhat.Line.From.X, DraggingWhat.Line.To.X), DraggingWhat.Slider.Position.Y);
  895. local Percent = (DraggingWhat.Slider.Position.X - DraggingWhat.Line.From.X) / ((DraggingWhat.Line.To.X - DraggingWhat.Line.From.X));
  896. local Value = CalculateValue(DraggingWhat.Min, DraggingWhat.Max, Percent);
  897. DraggingWhat.Option(Value);
  898. elseif DraggingUI then
  899. Debounce.UIDrag = true;
  900. local Main = Menu:GetInstance'Main';
  901. local MousePos = GetMouseLocation();
  902. Main.Position = MousePos + DragOffset;
  903. end
  904. else
  905. Dragging = false;
  906. if DraggingUI and Debounce.UIDrag then
  907. Debounce.UIDrag = false;
  908. DraggingUI = false;
  909. CreateMenu(Menu:GetInstance'Main'.Position);
  910. end
  911. end
  912. if not Debounce.Menu then
  913. Debounce.Menu = true;
  914. ToggleMenu();
  915. end
  916. elseif Debounce.Menu and not Options.MenuOpen.Value then
  917. Debounce.Menu = false;
  918. ToggleMenu();
  919. end
  920. end
  921.  
  922. RunService:UnbindFromRenderStep(GetDataName);
  923. RunService:UnbindFromRenderStep(UpdateName);
  924.  
  925. RunService:BindToRenderStep(GetDataName, 1, UpdatePlayerData);
  926. RunService:BindToRenderStep(UpdateName, 1, Update);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement