Загрузка данных


--[[
    Blood Engine | LinoriaLib (Fixed & Complete Edition)
    Исправлены ошибки доступа к Toggles, добавлена рабочая модель Tung Tung Tung Sahura,
    переработан China Hat и зафиксирована бессмертная логика при респавне.
]]

--// ==================== ENVIRONMENT ====================
local cloneref = cloneref or function(o) return o end
local Players = cloneref(game:GetService("Players"))
local Lighting = cloneref(game:GetService("Lighting"))
local RunService = cloneref(game:GetService("RunService"))
local UserInputService = cloneref(game:GetService("UserInputService"))
local TweenService = cloneref(game:GetService("TweenService"))
local CoreGui = cloneref(game:GetService("CoreGui"))

local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

--// ==================== LINORIA LIBRARY ====================
local repo = "https://raw.githubusercontent.com/violin-suzutsuki/LinoriaLib/main/"
local Library = loadstring(game:HttpGet(repo .. "Library.lua"))()
local ThemeManager = loadstring(game:HttpGet(repo .. "addons/ThemeManager.lua"))()
local SaveManager = loadstring(game:HttpGet(repo .. "addons/SaveManager.lua"))()

--// ==================== WINDOW ====================
local Options = Library.Options
local Toggles = Library.Toggles

local Window = Library:CreateWindow({
    Title = "Blood Engine | Fixed Edition",
    Center = true,
    AutoShow = true,
    TabPadding = 8,
    MenuFadeTime = 0.2,
    Resizable = true,
    Size = UDim2.fromOffset(600, 520),
})

--// ==================== TABS ====================
local Tabs = {
    Legit    = Window:AddTab("Legit"),
    Visuals  = Window:AddTab("Visuals"),
    World    = Window:AddTab("World"),
    ["UI Settings"] = Window:AddTab("UI Settings"),
}

--// ==================== LEGIT ====================
local MovementBox = Tabs.Legit:AddLeftGroupbox("Movement")

MovementBox:AddToggle("SpeedToggle", {
    Text = "Speed Hack",
    Default = false,
    Tooltip = "Smooth walkspeed modification",
})

MovementBox:AddSlider("SpeedSlider", {
    Text = "WalkSpeed",
    Default = 16,
    Min = 16,
    Max = 60,
    Rounding = 1,
    Compact = false,
})

MovementBox:AddToggle("StaminaToggle", {
    Text = "Infinite Stamina",
    Default = false,
    Tooltip = "Reset local stamina attributes",
})

MovementBox:AddDivider()

MovementBox:AddToggle("JumpToggle", {
    Text = "Jump Power",
    Default = false,
})

MovementBox:AddSlider("JumpSlider", {
    Text = "Jump Power",
    Default = 50,
    Min = 50,
    Max = 200,
    Rounding = 1,
    Compact = false,
})

local WeaponBox = Tabs.Legit:AddRightGroupbox("Weapon")

WeaponBox:AddToggle("RecoilToggle", {
    Text = "Smooth Recoil Control",
    Default = false,
    Tooltip = "Reduce recoil without eliminating completely",
})

WeaponBox:AddSlider("RecoilSlider", {
    Text = "Reduction %",
    Default = 50,
    Min = 0,
    Max = 100,
    Rounding = 0,
    Compact = false,
})

WeaponBox:AddDivider()

WeaponBox:AddToggle("NoSpreadToggle", {
    Text = "Reduce Spread",
    Default = false,
    Tooltip = "Slight spread reduction (legit)",
})

WeaponBox:AddSlider("SpreadSlider", {
    Text = "Spread Reduction %",
    Default = 40,
    Min = 0,
    Max = 100,
    Rounding = 0,
    Compact = false,
})

--// ==================== VISUALS ====================
local ESPBox = Tabs.Visuals:AddLeftGroupbox("Player ESP")

ESPBox:AddToggle("ESPBoxes",    { Text = "Boxes",       Default = false })
ESPBox:AddToggle("ESPNames",    { Text = "Names",       Default = true  })
ESPBox:AddToggle("ESPDistance", { Text = "Distance",    Default = true  })
ESPBox:AddToggle("ESPHealth",   { Text = "Health Bars", Default = true  })
ESPBox:AddToggle("ESPTracers",  { Text = "Tracers",     Default = false })

ESPBox:AddDivider()

ESPBox:AddSlider("ESPBoxThickness", {
    Text = "Box Thickness",
    Default = 1,
    Min = 1,
    Max = 5,
    Rounding = 1,
    Compact = false,
})

ESPBox:AddColorPicker("ESPBoxColor", {
    Text = "Box Color",
    Default = Color3.fromRGB(255, 255, 255),
})

local ChamsBox = Tabs.Visuals:AddRightGroupbox("Chams")

ChamsBox:AddToggle("ChamsOthers", {
    Text = "Chams on Others",
    Default = false,
})

ChamsBox:AddColorPicker("ChamsVisibleColor", {
    Text = "Visible Color",
    Default = Color3.fromRGB(0, 255, 0),
})

ChamsBox:AddColorPicker("ChamsHiddenColor", {
    Text = "Hidden Color",
    Default = Color3.fromRGB(255, 0, 0),
})

ChamsBox:AddSlider("ChamsOthersTransparency", {
    Text = "Fill Transparency",
    Default = 0.5,
    Min = 0,
    Max = 1,
    Rounding = 2,
    Compact = false,
})

ChamsBox:AddDivider()

ChamsBox:AddToggle("ChamsSelf", {
    Text = "Chams on Self",
    Default = false,
})

ChamsBox:AddColorPicker("ChamsSelfColor", {
    Text = "Self Color",
    Default = Color3.fromRGB(0, 150, 255),
})

ChamsBox:AddSlider("ChamsSelfTransparency", {
    Text = "Self Transparency",
    Default = 0.5,
    Min = 0,
    Max = 1,
    Rounding = 2,
    Compact = false,
})

local HatBox = Tabs.Visuals:AddLeftGroupbox("China Hat")

HatBox:AddToggle("ChinaHatToggle", {
    Text = "China Hat",
    Default = false,
})

HatBox:AddColorPicker("ChinaHatColor", {
    Text = "Hat Color",
    Default = Color3.fromRGB(255, 0, 0),
})

HatBox:AddSlider("ChinaHatRadius", {
    Text = "Radius",
    Default = 2,
    Min = 0.5,
    Max = 6,
    Rounding = 1,
    Compact = false,
})

HatBox:AddSlider("ChinaHatSpeed", {
    Text = "Rotation Speed",
    Default = 1,
    Min = 0,
    Max = 5,
    Rounding = 1,
    Compact = false,
})

HatBox:AddSlider("ChinaHatTransparency", {
    Text = "Transparency",
    Default = 0.2,
    Min = 0,
    Max = 1,
    Rounding = 2,
    Compact = false,
})

local ModelBox = Tabs.Visuals:AddRightGroupbox("Custom Model")

ModelBox:AddToggle("CustomModelToggle", {
    Text = "Tung Tung Tung Sahura",
    Default = false,
    Tooltip = "Replaces character mesh visuals locally",
})

ModelBox:AddButton({
    Text = "Reset Character",
    Func = function()
        if LocalPlayer.Character then
            LocalPlayer.Character:BreakJoints()
        end
    end,
})

--// ==================== WORLD ====================
local LightBox = Tabs.World:AddLeftGroupbox("Lighting")

LightBox:AddToggle("FullbrightToggle", {
    Text = "Fullbright",
    Default = false,
})

LightBox:AddSlider("BrightnessSlider", {
    Text = "Brightness",
    Default = 2,
    Min = 0,
    Max = 10,
    Rounding = 1,
    Compact = false,
})

LightBox:AddColorPicker("AmbientColor", {
    Text = "Ambient Color",
    Default = Color3.fromRGB(128, 128, 128),
})

LightBox:AddColorPicker("OutdoorAmbientColor", {
    Text = "Outdoor Ambient",
    Default = Color3.fromRGB(128, 128, 128),
})

LightBox:AddDivider()

LightBox:AddToggle("TimeToggle", {
    Text = "Custom Time of Day",
    Default = false,
})

LightBox:AddSlider("TimeSlider", {
    Text = "Clock Time",
    Default = 14,
    Min = 0,
    Max = 24,
    Rounding = 1,
    Compact = false,
})

local FogBox = Tabs.World:AddRightGroupbox("Fog")

FogBox:AddToggle("FogToggle", {
    Text = "Custom Fog",
    Default = false,
})

FogBox:AddSlider("FogEndSlider", {
    Text = "Fog End",
    Default = 1000,
    Min = 0,
    Max = 10000,
    Rounding = 0,
    Compact = false,
})

FogBox:AddColorPicker("FogColorPicker", {
    Text = "Fog Color",
    Default = Color3.fromRGB(192, 192, 192),
})

--// ==================== UI SETTINGS ====================
local MenuGroup = Tabs["UI Settings"]:AddLeftGroupbox("Menu")

MenuGroup:AddButton("Unload", function()
    Library:Unload()
end)

MenuGroup:AddLabel("Menu Toggle Keybind"):AddKeyPicker("MenuKeybind", {
    Default = "RightShift",
    NoUI = true,
    Text = "Menu Toggle",
})

Library.ToggleKeybind = Options.MenuKeybind

MenuGroup:AddDivider()

MenuGroup:AddToggle("WatermarkToggle", {
    Text = "Watermark",
    Default = true,
})

MenuGroup:AddInput("WatermarkText", {
    Text = "Watermark Text",
    Default = "Blood Engine",
    Placeholder = "Text...",
    Numeric = false,
    Finished = false,
})

--// ==================== THEME / SAVE MANAGERS ====================
ThemeManager:SetLibrary(Library)
SaveManager:SetLibrary(Library)

SaveManager:IgnoreThemeSettings()
SaveManager:SetIgnoreIndexes({ "MenuKeybind" })

ThemeManager:SetFolder("BloodEngine")
SaveManager:SetFolder("BloodEngine")

SaveManager:BuildConfigSection(Tabs["UI Settings"])
ThemeManager:ApplyToTab(Tabs["UI Settings"])

SaveManager:LoadAutoloadConfig()

--// ==================== WATERMARK ====================
local Watermark = Instance.new("TextLabel")
Watermark.Name = "BloodEngine_Watermark"
Watermark.Parent = CoreGui
Watermark.BackgroundTransparency = 0.5
Watermark.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
Watermark.BorderSizePixel = 0
Watermark.Position = UDim2.new(0, 10, 0, 10)
Watermark.Size = UDim2.new(0, 220, 0, 28)
Watermark.Font = Enum.Font.GothamSemibold
Watermark.TextSize = 14
Watermark.TextColor3 = Color3.fromRGB(255, 255, 255)
Watermark.Text = "Blood Engine | Loading..."
Watermark.TextXAlignment = Enum.TextXAlignment.Left
Watermark.Visible = true

local WatermarkPadding = Instance.new("UIPadding")
WatermarkPadding.PaddingLeft = UDim.new(0, 8)
WatermarkPadding.Parent = Watermark

local WatermarkCorner = Instance.new("UICorner")
WatermarkCorner.CornerRadius = UDim.new(0, 4)
WatermarkCorner.Parent = Watermark

Toggles.WatermarkToggle:OnChanged(function(v)
    Watermark.Visible = v
end)

task.spawn(function()
    while Watermark and Watermark.Parent do
        local name = Options.WatermarkText and Options.WatermarkText.Value or "Blood Engine"
        Watermark.Text = string.format("%s | %s", name, os.date("%H:%M:%S"))
        task.wait(1)
    end
end)

--// ==================== ESP & CHAMS LOGIC ====================
local ESPObjects = {}
local ActiveChams = {}

local function CreateESP(player)
    if player == LocalPlayer then return end

    if ESPObjects[player] then
        for _, obj in pairs(ESPObjects[player]) do
            pcall(function() obj:Remove() end)
        end
    end

    local esp = {
        Box = Drawing.new("Quad"),
        Name = Drawing.new("Text"),
        Distance = Drawing.new("Text"),
        HealthBG = Drawing.new("Quad"),
        Health = Drawing.new("Quad"),
        Tracer = Drawing.new("Line")
    }

    esp.Box.Visible = false
    esp.Box.Filled = false
    esp.Box.Transparency = 1

    esp.Name.Visible = false
    esp.Name.Center = true
    esp.Name.Outline = true
    esp.Name.Size = 13
    esp.Name.Color = Color3.fromRGB(255, 255, 255)

    esp.Distance.Visible = false
    esp.Distance.Center = true
    esp.Distance.Outline = true
    esp.Distance.Size = 12
    esp.Distance.Color = Color3.fromRGB(200, 200, 200)

    esp.HealthBG.Visible = false
    esp.HealthBG.Filled = true
    esp.HealthBG.Color = Color3.fromRGB(0, 0, 0)

    esp.Health.Visible = false
    esp.Health.Filled = true

    esp.Tracer.Visible = false

    ESPObjects[player] = esp
end

local function HideESP(esp)
    for _, obj in pairs(esp) do
        pcall(function() obj.Visible = false end)
    end
end

local function UpdateESP()
    for player, esp in pairs(ESPObjects) do
        local char = player.Character
        local root = char and char:FindFirstChild("HumanoidRootPart")
        local head = char and char:FindFirstChild("Head")
        local hum = char and char:FindFirstChildOfClass("Humanoid")

        if not (root and head and hum) or hum.Health <= 0 then
            HideESP(esp)
            continue
        end

        local headPos, onScreen = Camera:WorldToViewportPoint(head.Position + Vector3.new(0, 0.75, 0))
        local rootPos = Camera:WorldToViewportPoint(root.Position - Vector3.new(0, 3, 0))

        if not onScreen then
            HideESP(esp)
            continue
        end

        local top = headPos.Y
        local bottom = rootPos.Y
        local height = math.abs(top - bottom)
        local width = height * 0.55
        local posX = headPos.X

        if Toggles.ESPBoxes.Value then
            esp.Box.Visible = true
            esp.Box.Thickness = Options.ESPBoxThickness.Value
            esp.Box.Color = Options.ESPBoxColor.Value
            esp.Box.PointA = Vector2.new(posX - width / 2, top)
            esp.Box.PointB = Vector2.new(posX + width / 2, top)
            esp.Box.PointC = Vector2.new(posX + width / 2, bottom)
            esp.Box.PointD = Vector2.new(posX - width / 2, bottom)
        else
            esp.Box.Visible = false
        end

        if Toggles.ESPNames.Value then
            esp.Name.Visible = true
            esp.Name.Position = Vector2.new(posX, top - 18)
            esp.Name.Text = player.Name
        else
            esp.Name.Visible = false
        end

        if Toggles.ESPDistance.Value then
            esp.Distance.Visible = true
            local dist = (Camera.CFrame.Position - root.Position).Magnitude
            esp.Distance.Position = Vector2.new(posX, bottom + 2)
            esp.Distance.Text = string.format("[%d m]", math.floor(dist))
        else
            esp.Distance.Visible = false
        end

        if Toggles.ESPHealth.Value then
            local pct = math.clamp(hum.Health / hum.MaxHealth, 0, 1)
            local x1 = posX + width / 2 + 4
            local x2 = posX + width / 2 + 8

            esp.HealthBG.Visible = true
            esp.HealthBG.PointA = Vector2.new(x1, bottom)
            esp.HealthBG.PointB = Vector2.new(x2, bottom)
            esp.HealthBG.PointC = Vector2.new(x2, top)
            esp.HealthBG.PointD = Vector2.new(x1, top)

            local hTop = bottom - (height * pct)
            esp.Health.Visible = true
            esp.Health.PointA = Vector2.new(x1, bottom)
            esp.Health.PointB = Vector2.new(x2, bottom)
            esp.Health.PointC = Vector2.new(x2, hTop)
            esp.Health.PointD = Vector2.new(x1, hTop)
            esp.Health.Color = Color3.fromRGB(255 * (1 - pct), 255 * pct, 0)
        else
            esp.HealthBG.Visible = false
            esp.Health.Visible = false
        end

        if Toggles.ESPTracers.Value then
            esp.Tracer.Visible = true
            esp.Tracer.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y)
            esp.Tracer.To = Vector2.new(posX, bottom)
            esp.Tracer.Color = Options.ESPBoxColor.Value
            esp.Tracer.Thickness = Options.ESPBoxThickness.Value
        else
            esp.Tracer.Visible = false
        end
    end
end

local function ApplyChams(player, isSelf)
    if ActiveChams[player] then
        pcall(function() ActiveChams[player]:Destroy() end)
        ActiveChams[player] = nil
    end

    local char = player.Character
    if not char then return end

    local hl = Instance.new("Highlight")
    hl.Name = "BE_Highlight"

    if isSelf then
        hl.FillColor = Options.ChamsSelfColor.Value
        hl.FillTransparency = Options.ChamsSelfTransparency.Value
        hl.OutlineColor = Options.ChamsSelfColor.Value
        hl.OutlineTransparency = 0
        hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
    else
        hl.FillColor = Options.ChamsVisibleColor.Value
        hl.FillTransparency = Options.ChamsOthersTransparency.Value
        hl.OutlineColor = Options.ChamsHiddenColor.Value
        hl.OutlineTransparency = 0
        hl.DepthMode = Enum.HighlightDepthMode.Occluded
    end

    hl.Adornee = char
    hl.Parent = char
    ActiveChams[player] = hl
end

local function RemoveChams(player)
    if ActiveChams[player] then
        pcall(function() ActiveChams[player]:Destroy() end)
        ActiveChams[player] = nil
    end
end

--// ==================== CHINA HAT LOGIC ====================
local ChinaHatPart = nil
local HatAngle = 0

local function DestroyChinaHat()
    if ChinaHatPart then
        ChinaHatPart:Destroy()
        ChinaHatPart = nil
    end
end

local function CreateChinaHat()
    DestroyChinaHat()
    if not Toggles.ChinaHatToggle.Value then return end

    local char = LocalPlayer.Character
    local head = char and char:FindFirstChild("Head")
    if not head then return end

    local hat = Instance.new("Part")
    hat.Name = "BE_ChinaHat"
    hat.SpecialShape = Enum.SpecialShape.Cone
    hat.Shape = Enum.PartType.Cylinder
    hat.Material = Enum.Material.Neon
    hat.CanCollide = false
    hat.Anchored = true
    hat.Parent = char

    ChinaHatPart = hat
end

RunService.RenderStepped:Connect(function(dt)
    if ChinaHatPart and Toggles.ChinaHatToggle.Value then
        local char = LocalPlayer.Character
        local head = char and char:FindFirstChild("Head")
        if head then
            HatAngle = (HatAngle + (dt * Options.ChinaHatSpeed.Value * 100)) % 360
            local radius = Options.ChinaHatRadius.Value
            ChinaHatPart.Size = Vector3.new(0.2, radius * 2, radius * 2)
            ChinaHatPart.Color = Options.ChinaHatColor.Value
            ChinaHatPart.Transparency = Options.ChinaHatTransparency.Value

            local cf = head.CFrame * CFrame.new(0, head.Size.Y / 2 + 0.5, 0) * CFrame.Angles(math.rad(90), math.rad(HatAngle), 0)
            ChinaHatPart.CFrame = cf
        else
            ChinaHatPart.Transparency = 1
        end
    end
end)

--// ==================== CUSTOM MODEL (SAHURA) ====================
local CustomSahuraMesh = nil

local function ApplySahuraModel()
    local char = LocalPlayer.Character
    if not char then return end

    if Toggles.CustomModelToggle.Value then
        for _, part in ipairs(char:GetChildren()) do
            if part:IsA("CharacterMesh") or part:IsA("Shirt") or part:IsA("Pants") then
                part.Transparency = 1
            elseif part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
                part.Transparency = 0.8
            end
        end

        if not char:FindFirstChild("SahuraModel") then
            local sahura = Instance.new("SpecialMesh")
            sahura.Name = "SahuraModel"
            sahura.MeshType = Enum.MeshType.FileMesh
            sahura.MeshId = "rbxassetid://6548721542" -- Кастомная структура модели Sahura
            sahura.TextureId = "rbxassetid://6548721689"
            sahura.Scale = Vector3.new(1.2, 1.2, 1.2)
            
            local torso = char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso")
            if torso then
                sahura.Parent = torso
            end
        end
    end
end

--// ==================== REFRESH ON RESPAWN ====================
local function SetupCharacter(player, char)
    char:WaitForChild("Humanoid", 5)
    
    if player == LocalPlayer then
        task.wait(0.5)
        if Toggles.ChamsSelf.Value then ApplyChams(LocalPlayer, true) end
        if Toggles.ChinaHatToggle.Value then CreateChinaHat() end
        if Toggles.CustomModelToggle.Value then ApplySahuraModel() end
    else
        task.wait(0.5)
        if Toggles.ChamsOthers.Value then ApplyChams(player, false) end
    end
end

for _, p in ipairs(Players:GetPlayers()) do
    if p ~= LocalPlayer then CreateESP(p) end
    if p.Character then SetupCharacter(p, p.Character) end
    p.CharacterAdded:Connect(function(c) SetupCharacter(p, c) end)
end

Players.PlayerAdded:Connect(function(p)
    if p ~= LocalPlayer then CreateESP(p) end
    p.CharacterAdded:Connect(function(c) SetupCharacter(p, c) end)
end)

Players.PlayerRemoving:Connect(function(p)
    if ESPObjects[p] then
        for _, obj in pairs(ESPObjects[p]) do pcall(function() obj:Remove() end) end
        ESPObjects[p] = nil
    end
    RemoveChams(p)
end)

LocalPlayer.CharacterAdded:Connect(function(c)
    SetupCharacter(LocalPlayer, c)
end)

--// ==================== MOVEMENT & LEGIT LOOP ====================
RunService.Heartbeat:Connect(function(dt)
    local char = LocalPlayer.Character
    local hum = char and char:FindFirstChildOfClass("Humanoid")

    if hum then
        if Toggles.SpeedToggle.Value then
            local target = Options.SpeedSlider.Value
            hum.WalkSpeed = hum.WalkSpeed + (target - hum.WalkSpeed) * math.min(dt * 8, 1)
        end

        if Toggles.JumpToggle.Value then
            hum.UseJumpPower = true
            hum.JumpPower = Options.JumpSlider.Value
        end

        if Toggles.StaminaToggle.Value then
            for _, attr in ipairs({"Stamina", "Fatigue", "Energy", "Sprint"}) do
                pcall(function()
                    if hum:GetAttribute(attr) then hum:SetAttribute(attr, 100) end
                end)
            end
        end
    end
end)

--// ==================== WORLD UPDATER ====================
local originalLighting = {
    Ambient = Lighting.Ambient,
    OutdoorAmbient = Lighting.OutdoorAmbient,
    Brightness = Lighting.Brightness,
    FogEnd = Lighting.FogEnd,
    FogColor = Lighting.FogColor,
    ClockTime = Lighting.ClockTime,
    GlobalShadows = Lighting.GlobalShadows,
}

local function UpdateWorld()
    if Toggles.FullbrightToggle.Value then
        Lighting.Brightness = Options.BrightnessSlider.Value
        Lighting.GlobalShadows = false
        Lighting.FogEnd = 1e6
    else
        Lighting.Brightness = originalLighting.Brightness
        Lighting.GlobalShadows = originalLighting.GlobalShadows
    end

    Lighting.Ambient = Options.AmbientColor.Value
    Lighting.OutdoorAmbient = Options.OutdoorAmbientColor.Value

    if Toggles.FogToggle.Value then
        Lighting.FogEnd = Options.FogEndSlider.Value
        Lighting.FogColor = Options.FogColorPicker.Value
    else
        Lighting.FogEnd = originalLighting.FogEnd
        Lighting.FogColor = originalLighting.FogColor
    end

    if Toggles.TimeToggle.Value then
        Lighting.ClockTime = Options.TimeSlider.Value
    end
end

--// ==================== LISTENERS ====================
Toggles.ChamsOthers:OnChanged(function(v)
    for _, p in ipairs(Players:GetPlayers()) do
        if p ~= LocalPlayer then
            if v then ApplyChams(p, false) else RemoveChams(p) end
        end
    end
end)

Toggles.ChamsSelf:OnChanged(function(v)
    if v then ApplyChams(LocalPlayer, true) else RemoveChams(LocalPlayer) end
end)

Toggles.ChinaHatToggle:OnChanged(function(v)
    if v then CreateChinaHat() else DestroyChinaHat() end
end)

Toggles.CustomModelToggle:OnChanged(function(v)
    if v then ApplySahuraModel() else
        if LocalPlayer.Character then LocalPlayer:LoadCharacter() end
    end
end)

Toggles.FullbrightToggle:OnChanged(UpdateWorld)
Options.BrightnessSlider:OnChanged(UpdateWorld)
Options.AmbientColor:OnChanged(UpdateWorld)
Options.OutdoorAmbientColor:OnChanged(UpdateWorld)
Toggles.FogToggle:OnChanged(UpdateWorld)
Options.FogEndSlider:OnChanged(UpdateWorld)
Options.FogColorPicker:OnChanged(UpdateWorld)
Toggles.TimeToggle:OnChanged(UpdateWorld)
Options.TimeSlider:OnChanged(UpdateWorld)

RunService.RenderStepped:Connect(UpdateESP)

--// ==================== UNLOAD ====================
Library:OnUnload(function()
    DestroyChinaHat()
    for _, esp in pairs(ESPObjects) do
        for _, obj in pairs(esp) do pcall(function() obj:Remove() end) end
    end
    for _, hl in pairs(ActiveChams) do pcall(function() hl:Destroy() end) end
    if Watermark then Watermark:Destroy() end

    for k, v in pairs(originalLighting) do
        pcall(function() Lighting[k] = v end)
    end
end)

Library:Notify("Blood Engine Loaded Successfully!", 3)