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