-- ESP preview panel Library.EspPreviewSettings = { Enabled = false, Title = "ESP Preview", Width = 236, Height = 262, } Library.EspPreview = function(self, Options) Options = type(Options) == "table" and Options or { } local Existing = self.EspPreviewState if Existing and Existing.Frame and Existing.Frame.Instance and Existing.Frame.Instance.Parent then Existing.Frame.Instance:Destroy() end self.EspPreviewState = nil local Width = tonumber(Options.Width) or self.EspPreviewSettings.Width local Height = tonumber(Options.Height) or self.EspPreviewSettings.Height local Position = Options.Position if not Position then local Main = self.CurrentWindow and self.CurrentWindow.Items and self.CurrentWindow.Items["MainFrame"] local Scale = 1 if self.OverlayScale and self.OverlayScale.Instance.Scale > 0 then Scale = self.OverlayScale.Instance.Scale end if Main and Main.Instance then Position = UDim2New(0, (Main.Instance.AbsolutePosition.X + Main.Instance.AbsoluteSize.X + 12) / Scale, 0, Main.Instance.AbsolutePosition.Y / Scale) else Position = UDim2New(0, Camera.ViewportSize.X - Width - 24, 0, 90) end end local Items = { } Items["Root"] = Instances:Create("Frame", { Parent = Library.OverlayHolder.Instance, Name = "\0", Position = Position, Size = UDim2New(0, Width, 0, Height), BackgroundColor3 = FromRGB(21, 22, 25), BorderSizePixel = 0, ClipsDescendants = true, ZIndex = 4800 }) Items["Root"]:AddToTheme({ BackgroundColor3 = "Card" }) Instances:Create("UICorner", { Parent = Items["Root"].Instance, CornerRadius = UDimNew(0, 8) }) Instances:Create("UIStroke", { Parent = Items["Root"].Instance, Color = FromRGB(38, 39, 45), ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Transparency = 0.25 }):AddToTheme({ Color = "Border" }) Items["Band"] = Instances:Create("Frame", { Parent = Items["Root"].Instance, Name = "\0", Size = UDim2New(1, 0, 0, 28), Position = UDim2New(0, 0, 0, 0), BackgroundColor3 = FromRGB(28, 29, 33), BorderSizePixel = 0, ZIndex = 4801 }) Items["Band"]:AddToTheme({ BackgroundColor3 = "Card Header" }) Instances:Create("UICorner", { Parent = Items["Band"].Instance, CornerRadius = UDimNew(0, 8) }) for Index = 1, 2 do local Patch = Instances:Create("Frame", { Parent = Items["Band"].Instance, Name = "\0", Size = UDim2New(0, 10, 0, 10), Position = UDim2New(Index == 1 and 0 or 1, Index == 1 and 0 or -10, 1, -10), BackgroundColor3 = FromRGB(28, 29, 33), BorderSizePixel = 0, ZIndex = 4801 }) Patch:AddToTheme({ BackgroundColor3 = "Card Header" }) end Items["Title"] = Instances:Create("TextLabel", { Parent = Items["Root"].Instance, FontFace = Library.Font, Text = tostring(Options.Title or self.EspPreviewSettings.Title), Name = "\0", TextSize = 12, TextColor3 = FromRGB(122, 126, 134), BackgroundTransparency = 1, TextXAlignment = Enum.TextXAlignment.Left, AnchorPoint = Vector2New(0, 0.5), Position = UDim2New(0, 12, 0, 14), Size = UDim2New(1, -24, 0, 14), BorderSizePixel = 0, ZIndex = 4802, BackgroundColor3 = FromRGB(255, 255, 255) }) Items["Title"]:AddToTheme({ TextColor3 = "SubText" }) Instances:Create("Frame", { Parent = Items["Root"].Instance, Name = "\0", Size = UDim2New(1, 0, 0, 1), Position = UDim2New(0, 0, 0, 28), BackgroundColor3 = FromRGB(38, 39, 45), BorderSizePixel = 0, ZIndex = 4802 }):AddToTheme({ BackgroundColor3 = "Border" }) Items["Body"] = Instances:Create("Frame", { Parent = Items["Root"].Instance, Name = "\0", Position = UDim2New(0, 9, 0, 38), Size = UDim2New(1, -18, 1, -47), BackgroundColor3 = FromRGB(17, 18, 20), BorderSizePixel = 0, ZIndex = 4801 }) Items["Body"]:AddToTheme({ BackgroundColor3 = "Inline" }) Instances:Create("UICorner", { Parent = Items["Body"].Instance, CornerRadius = UDimNew(0, 6) }) Items["Viewport"] = Instances:Create("ViewportFrame", { Parent = Items["Body"].Instance, Name = "\0", Position = UDim2New(0, 6, 0, 6), Size = UDim2New(1, -12, 1, -12), BackgroundTransparency = 1, BorderSizePixel = 0, Ambient = FromRGB(140, 140, 150), LightColor = FromRGB(255, 255, 255), LightDirection = Vector3.new(-0.4, -1, -0.6), ZIndex = 4802 }) local Camera3D = InstanceNew("Camera") Camera3D.Parent = Items["Viewport"].Instance Items["Viewport"].Instance.CurrentCamera = Camera3D local DummyColor = typeof(Options.DummyColor) == "Color3" and Options.DummyColor or FromRGB(163, 162, 165) local function MakePart(Name, Size, Pos) local Part = InstanceNew("Part") Part.Name = Name Part.Size = Size Part.CFrame = CFrame.new(Pos) Part.Color = DummyColor Part.Material = Enum.Material.Plastic Part.Anchored = true Part.CanCollide = false Part.CanQuery = false Part.CanTouch = false Part.TopSurface = Enum.SurfaceType.Smooth Part.BottomSurface = Enum.SurfaceType.Smooth return Part end local Dummy = InstanceNew("Model") Dummy.Name = "PreviewDummy" local Root = MakePart("HumanoidRootPart", Vector3.new(2, 2, 1), Vector3.new(0, 0, 0)) Root.Transparency = 1 Root.Parent = Dummy MakePart("Torso", Vector3.new(2, 2, 1), Vector3.new(0, 0, 0)).Parent = Dummy local Head = MakePart("Head", Vector3.new(2, 1, 1), Vector3.new(0, 1.5, 0)) local HeadMesh = InstanceNew("SpecialMesh") HeadMesh.MeshType = Enum.MeshType.Head HeadMesh.Scale = Vector3.new(1.25, 1.25, 1.25) HeadMesh.Parent = Head Head.Parent = Dummy MakePart("Left Arm", Vector3.new(1, 2, 1), Vector3.new(-1.5, 0, 0)).Parent = Dummy MakePart("Right Arm", Vector3.new(1, 2, 1), Vector3.new(1.5, 0, 0)).Parent = Dummy MakePart("Left Leg", Vector3.new(1, 2, 1), Vector3.new(-0.5, -2, 0)).Parent = Dummy MakePart("Right Leg", Vector3.new(1, 2, 1), Vector3.new(0.5, -2, 0)).Parent = Dummy Dummy.PrimaryPart = Root Dummy.Parent = Items["Viewport"].Instance local Center, BoundSize = Dummy:GetBoundingBox() local Distance = math.max(BoundSize.X, BoundSize.Y, BoundSize.Z) * 1.55 local Yaw, Pitch = math.pi, 0 local Dragging, LastInput = false, nil local function ApplyPose() Dummy:PivotTo(CFrame.new(Center.Position) * CFrame.fromEulerAnglesYXZ(0, Yaw, 0) * CFrame.new(-Center.Position)) local Offset = CFrame.fromEulerAnglesYXZ(Pitch, 0, 0) * CFrame.new(0, BoundSize.Y * 0.1, Distance) Camera3D.CFrame = CFrame.new((Center * Offset).Position, Center.Position) end ApplyPose() Items["Overlay"] = Instances:Create("Frame", { Parent = Items["Body"].Instance, Name = "\0", Position = Items["Viewport"].Instance.Position, Size = Items["Viewport"].Instance.Size, BackgroundTransparency = 1, BorderSizePixel = 0, ClipsDescendants = true, ZIndex = 4803, Active = false }) local BoxParts, EdgeParts = { }, { } for Index, Name in { "LeftTop", "LeftSide", "RightSide", "BottomDown" } do local Holder = Instances:Create("Frame", { Parent = Items["Overlay"].Instance, Name = "\0", BackgroundColor3 = FromRGB(255, 255, 255), BorderSizePixel = 0, Position = UDim2New(0, 0, 0, 0), Visible = false, ZIndex = 4804 }) local Edge = Instances:Create("Frame", { Parent = Holder.Instance, Name = "\0", Size = UDim2New(1, 0, 1, 0), BackgroundColor3 = FromRGB(0, 0, 0), BorderSizePixel = 0, ZIndex = 4805 }) BoxParts[Index] = Holder EdgeParts[Index] = Edge end Items["Fill"] = Instances:Create("Frame", { Parent = Items["Overlay"].Instance, Name = "\0", BackgroundColor3 = FromRGB(255, 255, 255), BackgroundTransparency = 0.75, BorderSizePixel = 0, Visible = false, ZIndex = 4803 }) Items["BehindBar"] = Instances:Create("Frame", { Parent = Items["Overlay"].Instance, Name = "\0", BackgroundColor3 = FromRGB(0, 0, 0), BorderSizePixel = 0, Visible = false, ZIndex = 4804 }) Items["Bar"] = Instances:Create("Frame", { Parent = Items["Overlay"].Instance, Name = "\0", BackgroundColor3 = FromRGB(255, 255, 255), BorderSizePixel = 0, Visible = false, ZIndex = 4805 }) Instances:Create("UIGradient", { Parent = Items["Bar"].Instance, Enabled = true, Rotation = -90, Color = RGBSequence { RGBSequenceKeypoint(0, FromRGB(255, 0, 0)), RGBSequenceKeypoint(0.5, FromRGB(255, 140, 0)), RGBSequenceKeypoint(1, FromRGB(0, 255, 0)) } }) local function OverlayText(Name, Align) local Label = Instances:Create("TextLabel", { Parent = Items["Overlay"].Instance, Name = "\0", BackgroundTransparency = 1, Size = UDim2New(0, 200, 0, 18), AnchorPoint = Vector2New(0.5, Align == "Bottom" and 1 or 0), TextYAlignment = Align == "Bottom" and Enum.TextYAlignment.Bottom or Enum.TextYAlignment.Top, TextXAlignment = Enum.TextXAlignment.Center, FontFace = Library.Font, TextSize = 11, TextColor3 = FromRGB(255, 255, 255), TextStrokeTransparency = 0, TextStrokeColor3 = Color3.new(0, 0, 0), Text = "", Visible = false, ZIndex = 4806, BackgroundColor3 = FromRGB(255, 255, 255) }) return Label end local NameLabel = OverlayText("Name", "Bottom") local DistLabel = OverlayText("Distance", "Top") local ToolLabel = OverlayText("Weapon", "Top") local function Project(Point) local Relative = Camera3D.CFrame:PointToObjectSpace(Point) if Relative.Z >= -0.05 then return nil end local OverlaySize = Items["Overlay"].Instance.AbsoluteSize local Focal = (OverlaySize.Y / 2) / math.tan(math.rad(Camera3D.FieldOfView * 0.5)) return Vector2New((OverlaySize.X / 2) + (Relative.X / -Relative.Z) * Focal, (OverlaySize.Y / 2) - (Relative.Y / -Relative.Z) * Focal) end local function ScreenScale() local Scale = 1 local Node = Items["Overlay"].Instance while Node do for _, Child in ipairs(Node:GetChildren()) do if Child:IsA("UIScale") then Scale = Scale * Child.Scale end end if Node:IsA("ScreenGui") then break end Node = Node.Parent end if Scale <= 0 then Scale = 1 end return Scale end local function DrawPreview() local Overlay = Items["Overlay"].Instance if not Overlay.Parent or Overlay.AbsoluteSize.Y <= 8 then return end local Frag = getgenv().fragESP local Config = (Frag and Frag.config) or { } local BoxOn = Config.box ~= false local TextColor = Config.textvisible or FromRGB(255, 255, 255) local TextSize = tonumber(Config.textsize) or 11 local BarWidth = tonumber(Config.barwidth) or 2 local Extents = Frag and Frag.BodyExtents and Frag.BodyExtents(Dummy) local Points = Extents and { Extents.top, Extents.bottom, Extents.left, Extents.right } or { Center.Position + Vector3.yAxis * (BoundSize.Y / 2), Center.Position - Vector3.yAxis * (BoundSize.Y / 2), Center.Position - Camera3D.CFrame.RightVector * (math.max(BoundSize.X, BoundSize.Z) / 2), Center.Position + Camera3D.CFrame.RightVector * (math.max(BoundSize.X, BoundSize.Z) / 2), } local Hidden = function() for _, Part in BoxParts do Part.Instance.Visible = false end Items["Fill"].Instance.Visible = false Items["Bar"].Instance.Visible = false Items["BehindBar"].Instance.Visible = false NameLabel.Instance.Visible = false DistLabel.Instance.Visible = false ToolLabel.Instance.Visible = false end local Projected = { } for Index = 1, 4 do local Point = Project(Points[Index]) if not Point then Hidden() return end Projected[Index] = Point end local Scale = ScreenScale() local MinX, MaxX, MinY, MaxY = math.huge, -math.huge, math.huge, -math.huge for _, Point in Projected do MinX = math.min(MinX, Point.X) MaxX = math.max(MaxX, Point.X) MinY = math.min(MinY, Point.Y) MaxY = math.max(MaxY, Point.Y) end local LeftEdge = MinX / Scale local RightEdge = MaxX / Scale local CenterX = (LeftEdge + RightEdge) / 2 local HalfWidth = math.max((RightEdge - LeftEdge) / 2, 1.5) local TopY = MinY / Scale local BottomY = MaxY / Scale local BoxHeight = math.max(BottomY - TopY, 2) LeftEdge = CenterX - HalfWidth RightEdge = CenterX + HalfWidth local function Paint(Color) for _, Part in BoxParts do Part.Instance.BackgroundColor3 = Color end for _, Edge in EdgeParts do Edge.Instance.BackgroundColor3 = Color end NameLabel.Instance.TextColor3 = Color DistLabel.Instance.TextColor3 = Color ToolLabel.Instance.TextColor3 = Color Items["Fill"].Instance.BackgroundColor3 = Color end Paint(TextColor) if BoxOn then for _, Part in BoxParts do Part.Instance.Visible = true end BoxParts[1].Instance.Position = UDim2New(0, LeftEdge, 0, TopY) BoxParts[1].Instance.Size = UDim2New(0, HalfWidth * 2, 0, 1) BoxParts[1].Instance.AnchorPoint = Vector2New(0, 0) BoxParts[4].Instance.Position = UDim2New(0, LeftEdge, 0, BottomY) BoxParts[4].Instance.Size = UDim2New(0, HalfWidth * 2, 0, 1) BoxParts[4].Instance.AnchorPoint = Vector2New(0, 1) BoxParts[2].Instance.Position = UDim2New(0, LeftEdge, 0, TopY) BoxParts[2].Instance.Size = UDim2New(0, 1, 0, BoxHeight) BoxParts[2].Instance.AnchorPoint = Vector2New(0, 0) BoxParts[3].Instance.Position = UDim2New(0, RightEdge, 0, TopY) BoxParts[3].Instance.Size = UDim2New(0, 1, 0, BoxHeight) BoxParts[3].Instance.AnchorPoint = Vector2New(1, 0) else for _, Part in BoxParts do Part.Instance.Visible = false end end if Config.fillbox then local Fill = Items["Fill"].Instance Fill.Visible = true Fill.Position = UDim2New(0, LeftEdge, 0, TopY) Fill.Size = UDim2New(0, HalfWidth * 2, 0, BoxHeight) Fill.BackgroundTransparency = 1 - ((tonumber(Config.fillopacity) or 25) / 100) else Items["Fill"].Instance.Visible = false end if Config.healthbar then local Bar = Items["Bar"].Instance local Behind = Items["BehindBar"].Instance local Health = 0.68 Bar.Visible = true Bar.Position = UDim2New(0, LeftEdge - 5 - BarWidth, 0, TopY + BoxHeight * (1 - Health)) Bar.Size = UDim2New(0, BarWidth, 0, BoxHeight * Health) Bar.BorderColor3 = FromRGB(0, 0, 0) Behind.Visible = true Behind.Position = UDim2New(0, LeftEdge - 5 - BarWidth, 0, TopY) Behind.Size = UDim2New(0, BarWidth, 0, BoxHeight) Behind.BorderColor3 = FromRGB(0, 0, 0) else Items["Bar"].Instance.Visible = false Items["BehindBar"].Instance.Visible = false end for _, Label in { NameLabel, DistLabel, ToolLabel } do Label.Instance.TextSize = TextSize Label.Instance.Size = UDim2New(0, 200, 0, TextSize + 6) end if Config.name ~= false then NameLabel.Instance.Text = tostring(Options.TargetName or (LocalPlayer and LocalPlayer.Name) or "Target") NameLabel.Instance.Position = UDim2New(0, CenterX, 0, TopY - 4) NameLabel.Instance.Visible = true else NameLabel.Instance.Visible = false end local StackY = BottomY + (tonumber(Config.gap) or 5) local Step = tonumber(Config.linegap) or 10 if Config.distance == true then DistLabel.Instance.Text = tostring(math.floor(Distance)) .. " studs" DistLabel.Instance.Position = UDim2New(0, CenterX, 0, StackY) DistLabel.Instance.Visible = true StackY = StackY + Step else DistLabel.Instance.Visible = false end if Config.weapon == true then local Character = LocalPlayer and LocalPlayer.Character local Tool = Character and Character:FindFirstChildOfClass("Tool") ToolLabel.Instance.Text = Tool and Tool.Name or "None" ToolLabel.Instance.Position = UDim2New(0, CenterX, 0, StackY) ToolLabel.Instance.Visible = true else ToolLabel.Instance.Visible = false end end Library:Connect(Items["Viewport"].Instance.InputBegan, function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then Dragging = true LastInput = Input.Position end end) Library:Connect(Items["Viewport"].Instance.InputEnded, function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then Dragging = false LastInput = nil end end) Library:Connect(UserInputService.InputChanged, function(Input) if not Dragging or not LastInput then return end if Input.UserInputType ~= Enum.UserInputType.MouseMovement and Input.UserInputType ~= Enum.UserInputType.Touch then return end local DeltaX = Input.Position.X - LastInput.X local DeltaY = Input.Position.Y - LastInput.Y LastInput = Input.Position Yaw = Yaw - DeltaX * 0.012 Pitch = MathClamp(Pitch + DeltaY * 0.012, -math.rad(78), math.rad(78)) ApplyPose() end) local Accumulator = 0 Library:Connect(RunService.RenderStepped, function(Delta) if not Items["Root"].Instance.Parent or not Dummy.Parent then return end Accumulator = Accumulator + Delta if Accumulator < 1 / 30 then return end local Step = Accumulator Accumulator = 0 if not Dragging then Yaw = Yaw + Step * 0.6 end ApplyPose() DrawPreview() end) Items["Root"]:MakeDraggable(Items["Band"]) local Preview = { Gui = Items["Root"], Frame = Items["Root"], Viewport = Items["Viewport"], Overlay = Items["Overlay"], Dummy = Dummy, Camera3D = Camera3D, Draw = DrawPreview, Items = Items, } function Preview:SetVisible(Bool) Items["Root"].Instance.Visible = Bool == true end function Preview:Destroy() if Items["Root"].Instance then Items["Root"].Instance:Destroy() end end self.EspPreviewSettings.Enabled = true self.EspPreviewState = Preview task.defer(function() Library:KeepOnScreen(Items["Root"], Library.OverlayHolder.Instance) end) return Preview end Library.SetEspPreview = function(self, Bool, Options) self.EspPreviewSettings.Enabled = Bool and true or false if Bool then return self:EspPreview(Options) end local Existing = self.EspPreviewState if Existing and Existing.Frame and Existing.Frame.Instance then Existing.Frame.Instance:Destroy() end self.EspPreviewState = nil return nil end