Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Universal Box ESP (Works on Arsenal and other games)
- -- settings
- local settings = {
- defaultcolor = Color3.fromRGB(255,0,0),
- teamcheck = false,
- teamcolor = true
- };
- -- services
- local runService = game:GetService("RunService");
- local players = game:GetService("Players");
- -- variables
- local localPlayer = players.LocalPlayer;
- local camera = workspace.CurrentCamera;
- -- functions
- local newVector2, newColor3, newDrawing = Vector2.new, Color3.new, Drawing.new;
- local tan, rad = math.tan, math.rad;
- local round = function(...) local a = {}; for i,v in next, table.pack(...) do a[i] = math.round(v); end return unpack(a); end;
- local wtvp = function(...) local a, b = camera.WorldToViewportPoint(camera, ...) return newVector2(a.X, a.Y), b, a.Z end;
- local espCache = {};
- local function createEsp(player)
- local drawings = {};
- drawings.box = newDrawing("Square");
- drawings.box.Thickness = 1;
- drawings.box.Filled = false;
- drawings.box.Color = settings.defaultcolor;
- drawings.box.Visible = false;
- drawings.box.ZIndex = 2;
- drawings.boxoutline = newDrawing("Square");
- drawings.boxoutline.Thickness = 3;
- drawings.boxoutline.Filled = false;
- drawings.boxoutline.Color = newColor3();
- drawings.boxoutline.Visible = false;
- drawings.boxoutline.ZIndex = 1;
- espCache[player] = drawings;
- end
- local function removeEsp(player)
- if rawget(espCache, player) then
- for _, drawing in next, espCache[player] do
- drawing:Remove();
- end
- espCache[player] = nil;
- end
- end
- local function updateEsp(player, esp)
- local character = player and player.Character;
- if character then
- local cframe = character:GetModelCFrame();
- local position, visible, depth = wtvp(cframe.Position);
- esp.box.Visible = visible;
- esp.boxoutline.Visible = visible;
- if cframe and visible then
- local scaleFactor = 1 / (depth * tan(rad(camera.FieldOfView / 2)) * 2) * 1000;
- local width, height = round(4 * scaleFactor, 5 * scaleFactor);
- local x, y = round(position.X, position.Y);
- esp.box.Size = newVector2(width, height);
- esp.box.Position = newVector2(round(x - width / 2, y - height / 2));
- esp.box.Color = settings.teamcolor and player.TeamColor.Color or settings.defaultcolor;
- esp.boxoutline.Size = esp.box.Size;
- esp.boxoutline.Position = esp.box.Position;
- end
- else
- esp.box.Visible = false;
- esp.boxoutline.Visible = false;
- end
- end
- -- main
- for _, player in next, players:GetPlayers() do
- if player ~= localPlayer then
- createEsp(player);
- end
- end
- players.PlayerAdded:Connect(function(player)
- createEsp(player);
- end);
- players.PlayerRemoving:Connect(function(player)
- removeEsp(player);
- end)
- runService:BindToRenderStep("esp", Enum.RenderPriority.Camera.Value, function()
- for player, drawings in next, espCache do
- if settings.teamcheck and player.Team == localPlayer.Team then
- continue;
- end
- if drawings and player ~= localPlayer then
- updateEsp(player, drawings);
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement