YM TOOL
Key RequiredUniversal

YM TOOL

Universal Scriptcookichocscookichocs 1.7K views 1.6K executesUpdated Sep 16, 2026
2.5/ 5(2 votes)
1150% Positive
Lua Script•3717 lines (156802 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local VirtualUser = game:GetService("VirtualUser")
local Camera = workspace.CurrentCamera
local Mouse = Players.LocalPlayer:GetMouse()
local player = Players.LocalPlayer


local cursorIsForced = false
local savedMouseBehavior = nil
local savedMouseIconEnabled = nil
local CURSOR_RENDER_STEP = "YM_ForceFreeCursor"

local function setCursorForced(visible)
	if visible then
		if not cursorIsForced then
			savedMouseBehavior = UserInputService.MouseBehavior
			savedMouseIconEnabled = UserInputService.MouseIconEnabled
			cursorIsForced = true

			pcall(function()
				RunService:UnbindFromRenderStep(CURSOR_RENDER_STEP)
				RunService:BindToRenderStep(CURSOR_RENDER_STEP, Enum.RenderPriority.Last.Value, function()
					if cursorIsForced then
						UserInputService.MouseBehavior = Enum.MouseBehavior.Default
						UserInputService.MouseIconEnabled = true
					end
				end)
			end)
		end
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default
		UserInputService.MouseIconEnabled = true
	elseif cursorIsForced then
		cursorIsForced = false
		pcall(function()
			RunService:UnbindFromRenderStep(CURSOR_RENDER_STEP)
		end)
		if savedMouseBehavior then
			UserInputService.MouseBehavior = savedMouseBehavior
		end
		if savedMouseIconEnabled ~= nil then
			UserInputService.MouseIconEnabled = savedMouseIconEnabled
		end
	end
end


local WINDOW_BACKGROUND_IMAGE = "rbxassetid://100446752830441"
local BUTTON_BACKGROUND_IMAGE = "rbxassetid://115507210213862"

local function addButtonBackground(button)
	if not button or not button:IsA("GuiButton") then return end
	if button:FindFirstChild("YM_ButtonBackground") then return end

	-- Trois couches totalement séparées :
	-- 10 = image, 20 = bouton/clique, 30 = texte.
	-- Le TextLabel est un enfant du bouton et Active=false, donc il ne bloque pas le clic.
	button.BackgroundTransparency = math.max(button.BackgroundTransparency, 0.65)
	button.ZIndex = 20

	local background = Instance.new("ImageLabel")
	background.Name = "YM_ButtonBackground"
	background.Size = UDim2.fromScale(1, 1)
	background.Position = UDim2.fromScale(0, 0)
	background.BackgroundTransparency = 1
	background.Image = BUTTON_BACKGROUND_IMAGE
	background.ImageTransparency = 0.12
	background.ScaleType = Enum.ScaleType.Crop
	background.BorderSizePixel = 0
	background.Active = false
	background.Selectable = false
	background.ZIndex = 10
	background.Parent = button

	if button:IsA("TextButton") then
		-- On cache le texte natif du TextButton : le vrai texte est dans YM_ButtonText.
		button.TextTransparency = 1
		button.TextStrokeTransparency = 1

		local textLabel = Instance.new("TextLabel")
		textLabel.Name = "YM_ButtonText"
		textLabel.Size = UDim2.fromScale(1, 1)
		textLabel.Position = UDim2.fromScale(0, 0)
		textLabel.BackgroundTransparency = 1
		textLabel.Text = button.Text
		textLabel.TextColor3 = button.TextColor3
		textLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		textLabel.TextStrokeTransparency = 0
		textLabel.TextTransparency = 0
		textLabel.Font = button.Font
		textLabel.TextSize = button.TextSize
		textLabel.TextScaled = button.TextScaled
		textLabel.TextWrapped = button.TextWrapped
		textLabel.TextXAlignment = button.TextXAlignment
		textLabel.TextYAlignment = button.TextYAlignment
		textLabel.RichText = button.RichText
		textLabel.Active = false
		textLabel.Selectable = false
		textLabel.ZIndex = 30
		textLabel.Parent = button

		-- Le texte reste synchronisé avec les changements OFF/ON du bouton.
		button:GetPropertyChangedSignal("Text"):Connect(function()
			if textLabel.Parent then
				textLabel.Text = button.Text
			end
		end)
		button:GetPropertyChangedSignal("TextColor3"):Connect(function()
			if textLabel.Parent then
				textLabel.TextColor3 = button.TextColor3
			end
		end)
	end
end

local function addWindowBackground(frame)
	if not frame or not frame:IsA("GuiObject") then return end
	if frame:FindFirstChild("YM_WindowBackground") then return end


	frame.BackgroundTransparency = 0.25

	local background = Instance.new("ImageLabel")
	background.Name = "YM_WindowBackground"
	background.Size = UDim2.fromScale(1, 1)
	background.Position = UDim2.fromScale(0, 0)
	background.BackgroundTransparency = 1
	background.Image = WINDOW_BACKGROUND_IMAGE
	
	background.ImageTransparency = 0.08
	background.ScaleType = Enum.ScaleType.Crop
	background.BorderSizePixel = 0
	background.Active = false
	background.Selectable = false
	background.ZIndex = 1
	background.Parent = frame


	for _, obj in ipairs(frame:GetDescendants()) do
		if obj:IsA("GuiObject") and obj ~= background then
			obj.ZIndex = math.max(obj.ZIndex + 1, 2)
		end
	end

	
	for _, obj in ipairs(frame:GetDescendants()) do
		if obj:IsA("GuiButton") then
			addButtonBackground(obj)
		end
	end
end



local function protect()
	pcall(function()
		for _, v in pairs(game:GetService("CoreGui"):GetChildren()) do
			if typeof(v.Name) == "string" and (v.Name:find("YM") or v.Name:find("Core") or v.Name:find("Password")) then
				v.Name = "Core" .. math.random(100000, 999999)
			end
		end
	end)
end
protect()


local PassGui = Instance.new("ScreenGui")
PassGui.Name = "Core" .. math.random(100000, 999999)
PassGui.ResetOnSpawn = false
PassGui.Parent = player:WaitForChild("PlayerGui")
setCursorForced(true)

local PassFrame = Instance.new("Frame")
PassFrame.Size = UDim2.new(0, 340, 0, 245)
PassFrame.Position = UDim2.new(0.5, -170, 0.5, -100)
PassFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
PassFrame.Parent = PassGui
Instance.new("UICorner", PassFrame).CornerRadius = UDim.new(0, 12)
Instance.new("UIStroke", PassFrame).Color = Color3.fromRGB(160, 0, 0)

local PassTitle = Instance.new("TextLabel")
PassTitle.Size = UDim2.new(1, 0, 0, 50)
PassTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
PassTitle.Text = "YM TOOL"
PassTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
PassTitle.Font = Enum.Font.GothamBlack
PassTitle.TextSize = 26
PassTitle.Parent = PassFrame
Instance.new("UICorner", PassTitle).CornerRadius = UDim.new(0, 12)

local PassLabel = Instance.new("TextLabel")
PassLabel.Size = UDim2.new(1, -40, 0, 25)
PassLabel.Position = UDim2.new(0, 20, 0, 60)
PassLabel.BackgroundTransparency = 1
PassLabel.Text = "Entre le mot de passe :"
PassLabel.TextColor3 = Color3.fromRGB(200, 160, 160)
PassLabel.Font = Enum.Font.Gotham
PassLabel.TextSize = 14
PassLabel.TextXAlignment = Enum.TextXAlignment.Left
PassLabel.Parent = PassFrame

local PassBox = Instance.new("TextBox")
PassBox.Size = UDim2.new(1, -40, 0, 36)
PassBox.Position = UDim2.new(0, 20, 0, 90)
PassBox.BackgroundColor3 = Color3.fromRGB(25, 8, 8)
PassBox.PlaceholderText = "Mot de passe..."
PassBox.Text = ""
PassBox.TextColor3 = Color3.fromRGB(255, 220, 220)
PassBox.Font = Enum.Font.GothamBold
PassBox.TextSize = 16
PassBox.Parent = PassFrame
Instance.new("UICorner", PassBox).CornerRadius = UDim.new(0, 6)

local PassBtn = Instance.new("TextButton")
PassBtn.Size = UDim2.new(1, -40, 0, 38)
PassBtn.Position = UDim2.new(0, 20, 0, 135)
PassBtn.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
PassBtn.Text = "ENTRER"
PassBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
PassBtn.Font = Enum.Font.GothamBold
PassBtn.TextSize = 16
PassBtn.Parent = PassFrame
Instance.new("UICorner", PassBtn).CornerRadius = UDim.new(0, 6)

local DevBtn = Instance.new("TextButton")
DevBtn.Size = UDim2.new(1, -40, 0, 32)
DevBtn.Position = UDim2.new(0, 20, 0, 178)
DevBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
DevBtn.Text = "JE SUIS DÉVELOPPEUR"
DevBtn.TextColor3 = Color3.fromRGB(235, 235, 235)
DevBtn.Font = Enum.Font.GothamBold
DevBtn.TextSize = 13
DevBtn.Parent = PassFrame
Instance.new("UICorner", DevBtn).CornerRadius = UDim.new(0, 6)

local ErrorLabel = Instance.new("TextLabel")
ErrorLabel.Size = UDim2.new(1, -20, 0, 20)
ErrorLabel.Position = UDim2.new(0, 10, 1, -25)
ErrorLabel.BackgroundTransparency = 1
ErrorLabel.Text = ""
ErrorLabel.TextColor3 = Color3.fromRGB(255, 60, 60)
ErrorLabel.Font = Enum.Font.Gotham
ErrorLabel.TextSize = 13
ErrorLabel.Parent = PassFrame

addWindowBackground(PassFrame)

local StaffFrame = Instance.new("Frame")
StaffFrame.Size = UDim2.new(1, 0, 1, 0)
StaffFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
StaffFrame.ZIndex = 100
StaffFrame.Visible = false
StaffFrame.Parent = PassFrame
Instance.new("UICorner", StaffFrame).CornerRadius = UDim.new(0, 12)

local StaffTitle = Instance.new("TextLabel")
StaffTitle.Size = UDim2.new(1, 0, 0, 50)
StaffTitle.ZIndex = 101
StaffTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
StaffTitle.Text = "YM TOOL • STAFF"
StaffTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
StaffTitle.Font = Enum.Font.GothamBlack
StaffTitle.TextSize = 22
StaffTitle.Parent = StaffFrame
Instance.new("UICorner", StaffTitle).CornerRadius = UDim.new(0, 12)

local StaffLabel = Instance.new("TextLabel")
StaffLabel.Size = UDim2.new(1, -40, 0, 25)
StaffLabel.ZIndex = 101
StaffLabel.Position = UDim2.new(0, 20, 0, 60)
StaffLabel.BackgroundTransparency = 1
StaffLabel.Text = "Mot de passe développeur :"
StaffLabel.TextColor3 = Color3.fromRGB(200, 160, 160)
StaffLabel.Font = Enum.Font.Gotham
StaffLabel.TextSize = 14
StaffLabel.TextXAlignment = Enum.TextXAlignment.Left
StaffLabel.Parent = StaffFrame

local StaffBox = Instance.new("TextBox")
StaffBox.Size = UDim2.new(1, -40, 0, 36)
StaffBox.ZIndex = 101
StaffBox.Position = UDim2.new(0, 20, 0, 90)
StaffBox.BackgroundColor3 = Color3.fromRGB(25, 8, 8)
StaffBox.PlaceholderText = "Mot de passe développeur..."
StaffBox.Text = ""
StaffBox.TextColor3 = Color3.fromRGB(255, 220, 220)
StaffBox.Font = Enum.Font.GothamBold
StaffBox.TextSize = 16
StaffBox.Parent = StaffFrame
Instance.new("UICorner", StaffBox).CornerRadius = UDim.new(0, 6)

local StaffBtn = Instance.new("TextButton")
StaffBtn.Size = UDim2.new(1, -40, 0, 38)
StaffBtn.ZIndex = 101
StaffBtn.Position = UDim2.new(0, 20, 0, 140)
StaffBtn.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
StaffBtn.Text = "VALIDER"
StaffBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
StaffBtn.Font = Enum.Font.GothamBold
StaffBtn.TextSize = 16
StaffBtn.Parent = StaffFrame
Instance.new("UICorner", StaffBtn).CornerRadius = UDim.new(0, 6)

local StaffBackBtn = Instance.new("TextButton")
StaffBackBtn.Size = UDim2.new(1, -40, 0, 32)
StaffBackBtn.ZIndex = 101
StaffBackBtn.Position = UDim2.new(0, 20, 0, 184)
StaffBackBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 50)
StaffBackBtn.Text = "RETOUR"
StaffBackBtn.TextColor3 = Color3.fromRGB(235, 235, 235)
StaffBackBtn.Font = Enum.Font.GothamBold
StaffBackBtn.TextSize = 13
StaffBackBtn.Parent = StaffFrame
Instance.new("UICorner", StaffBackBtn).CornerRadius = UDim.new(0, 6)

local StaffError = Instance.new("TextLabel")
StaffError.Size = UDim2.new(1, -20, 0, 20)
StaffError.ZIndex = 101
StaffError.Position = UDim2.new(0, 10, 1, -25)
StaffError.BackgroundTransparency = 1
StaffError.Text = ""
StaffError.TextColor3 = Color3.fromRGB(255, 60, 60)
StaffError.Font = Enum.Font.Gotham
StaffError.TextSize = 13
StaffError.Parent = StaffFrame

local correctPassword = "ymclxn"
local developerPassword = "staff6194"
local scriptLoaded = false

-- =====================================================
-- THEME EDITOR / PERSONNALISATION
-- =====================================================
local function buildThemeEditor(ctx)
    local ScreenGui, Main, Content, Sidebar = ctx.ScreenGui, ctx.Main, ctx.Content, ctx.Sidebar
    local Background, categoryButtons, pages = ctx.Background, ctx.categoryButtons, ctx.pages
    local player, RunService, HttpService, SearchBox, ContentTitle = ctx.player, ctx.RunService, ctx.HttpService, ctx.SearchBox, ctx.ContentTitle
    local INITIAL_MAIN_POSITION = ctx.InitialMainPosition
    local Title = ctx.Title
    local WindowHeader = ctx.WindowHeader
    local WINDOW_BACKGROUND_IMAGE, BUTTON_BACKGROUND_IMAGE = ctx.WINDOW_BACKGROUND_IMAGE, ctx.BUTTON_BACKGROUND_IMAGE

    local State = {
        primary = Color3.fromRGB(180, 0, 0), transparency = 0.15,
        background = WINDOW_BACKGROUND_IMAGE, buttonImage = BUTTON_BACKGROUND_IMAGE,
        skyRGB = false, skyColor = Color3.fromRGB(255, 40, 40), skyImage = nil,
        _skyBackup = nil, _skyWasCreated = false, _skyName = nil, _skyObject = nil, _skyTint = nil,
        _skyEnvBackup = nil,
        _memoryPresets = {}, _connections = {},
    }
    local skyRGBConnection, activeModal, pickerCallback = nil, nil, nil
    local presetFolder = "YM_TOOL_PRESETS"

    local function uri(value)
        local id = tostring(value or ""):match("%d+")
        return id and ("rbxassetid://" .. id) or nil
    end
    local function blend(c, amount) return c:Lerp(Color3.new(0,0,0), amount) end
    local function closeModal()
        if activeModal then activeModal:Destroy(); activeModal = nil end
        pickerCallback = nil
    end
    local function dragify(frame, handle)
        handle = handle or frame
        local dragging, dragStart, startPos = false, nil, nil
        handle.InputBegan:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                dragging, dragStart, startPos = true, input.Position, frame.Position
                input.Changed:Connect(function()
                    if input.UserInputState == Enum.UserInputState.End then dragging = false end
                end)
            end
        end)
        UserInputService.InputChanged:Connect(function(input)
            if not dragging then return end
            if input.UserInputType ~= Enum.UserInputType.MouseMovement and input.UserInputType ~= Enum.UserInputType.Touch then return end
            local delta = input.Position - dragStart
            frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end)
    end
    local function notify(message, good)
        local toast = Instance.new("TextLabel")
        toast.Name = "YM_ThemeToast"; toast.Size = UDim2.fromOffset(320, 42)
        toast.AnchorPoint = Vector2.new(0.5, 1); toast.Position = UDim2.new(0.5, 0, 1, -18)
        toast.BackgroundColor3 = good and Color3.fromRGB(18, 80, 35) or Color3.fromRGB(100, 20, 20)
        toast.TextColor3 = Color3.new(1,1,1); toast.Font = Enum.Font.GothamBold; toast.TextSize = 13
        toast.Text = message; toast.ZIndex = 500; toast.Parent = ScreenGui
        Instance.new("UICorner", toast).CornerRadius = UDim.new(0, 8)
        task.delay(2.2, function() if toast.Parent then toast:Destroy() end end)
    end

    local function applyPrimaryColor(color)
        State.primary = color
        local dark = blend(color, 0.72)
        local darker = blend(color, 0.88)
        local border = color:Lerp(Color3.new(1,1,1), 0.08)
        local bright = color:Lerp(Color3.new(1,1,1), 0.22)
        Main.BackgroundColor3 = darker
        if Background then Background.BackgroundColor3 = darker end
        Sidebar.BackgroundColor3 = blend(color, 0.90)
        Content.BackgroundColor3 = blend(color, 0.90)
        SearchBox.BackgroundColor3 = blend(color, 0.68)
        SearchBox.PlaceholderColor3 = bright
        if Title then Title.TextColor3 = bright end
        if ContentTitle then ContentTitle.TextColor3 = bright end
        if WindowHeader then WindowHeader.BackgroundColor3 = blend(color, 0.78) end
        for _, btn in pairs(categoryButtons) do btn.BackgroundColor3 = dark end
        for _, root in ipairs({Main, ScreenGui}) do
            for _, obj in ipairs(root:GetDescendants()) do
                if obj:IsA("UIStroke") then
                    obj.Color = border
                    obj.Transparency = 0
                elseif obj:IsA("ScrollingFrame") then
                    obj.ScrollBarImageColor3 = color
                    obj.ScrollBarImageTransparency = 0
                elseif obj:IsA("TextButton") then
                    obj.BackgroundColor3 = dark
                    obj.AutoButtonColor = false
                elseif obj:IsA("ImageButton") then
                    obj.BackgroundColor3 = dark
                elseif obj:IsA("GuiObject") and obj.BorderSizePixel > 0 then
                    obj.BorderColor3 = border
                end
            end
        end
    end
    local function applyTransparency(value)
        State.transparency = math.clamp(tonumber(value) or State.transparency, 0, 1)
        -- Keep the main window anchored at its original position whenever transparency changes.
        Main.Position = INITIAL_MAIN_POSITION

        -- Every interface surface follows the same transparency value. This prevents
        -- default/grey GuiObject backgrounds from being exposed underneath the theme.
        Main.BackgroundTransparency = State.transparency
        Content.BackgroundTransparency = State.transparency
        Sidebar.BackgroundTransparency = State.transparency
        SearchBox.BackgroundTransparency = State.transparency

        if Background then
            Background.BackgroundTransparency = 1
            Background.ImageTransparency = State.transparency
        end

        for _, obj in ipairs(Main:GetDescendants()) do
            if obj:IsA("GuiObject") and obj ~= Background then
                -- Never let a default GuiObject background turn grey as the theme fades.
                obj.BackgroundTransparency = State.transparency
            end
            if obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
                obj.ImageTransparency = State.transparency
            end
        end
        if Background then
            -- The background image has no own colour layer; otherwise Roblox can expose a grey/white rectangle.
            Background.BackgroundTransparency = 1
        end

        -- Text-only elements should never expose their default background.
        for _, obj in ipairs(Main:GetDescendants()) do
            if obj:IsA("TextLabel") or obj:IsA("TextButton") or obj:IsA("TextBox") then
                obj.BackgroundTransparency = State.transparency
            end
        end
    end
    local function setThemeBackground(image)
        local id = uri(image); if not id then return false end
        State.background = id; Background.Image = id; return true
    end
    local function setThemeButtonImage(image)
        local id = uri(image); if not id then return false end
        State.buttonImage = id
        for _, obj in ipairs(Main:GetDescendants()) do
            if obj:IsA("ImageLabel") and obj.Name == "YM_ButtonBackground" then obj.Image = id end
        end
        return true
    end

    local function getSky()
        local Lighting = game:GetService("Lighting")
        local sky = State._skyObject
        if not sky or not sky.Parent then
            sky = Lighting:FindFirstChildOfClass("Sky")
            if not sky then
                sky = Instance.new("Sky")
                sky.Name = "YM_TOOL_Sky"
                sky.Parent = Lighting
                State._skyWasCreated = true
            elseif not State._skyBackup then
                State._skyBackup = {sky.SkyboxBk, sky.SkyboxDn, sky.SkyboxFt, sky.SkyboxLf, sky.SkyboxRt, sky.SkyboxUp}
                State._skyName = sky.Name
                State._skyWasCreated = false
            end
            State._skyObject = sky
        end
        return sky
    end

    local function backupSkyEnvironment()
        local Lighting = game:GetService("Lighting")
        if not State._skyEnvBackup then
            State._skyEnvBackup = {
                Ambient = Lighting.Ambient,
                OutdoorAmbient = Lighting.OutdoorAmbient,
                ColorShiftTop = Lighting.ColorShift_Top,
                ColorShiftBottom = Lighting.ColorShift_Bottom,
            }
        end
    end

    local function getDecorColorCorrection()
        local Lighting = game:GetService("Lighting")
        local fx = Lighting:FindFirstChild("YM_TOOL_DecorTint")
        if not fx or not fx:IsA("ColorCorrectionEffect") then
            if fx then fx:Destroy() end
            fx = Instance.new("ColorCorrectionEffect")
            fx.Name = "YM_TOOL_DecorTint"
            fx.Parent = Lighting
        end
        return fx
    end

    local function applyStrongDecorTint(color)
        local fx = getDecorColorCorrection()
        -- Strong, visible tint across the rendered 3D decor/sky, while leaving the UI untouched.
        fx.TintColor = Color3.new(1,1,1):Lerp(color, 0.72)
        fx.Saturation = 0.18
        fx.Contrast = 0.08
        fx.Brightness = 0.02
    end

    local function applySkyColor(color)
        State.skyColor = color
        local Lighting = game:GetService("Lighting")
        backupSkyEnvironment()
        -- Strong scene-wide tint: the whole 3D decor and sky visibly take the chosen colour.
        local strength = 0.58
        local tint = Color3.new(1,1,1):Lerp(color, strength)
        local base = State._skyEnvBackup
        if base then
            Lighting.Ambient = base.Ambient:Lerp(tint, strength)
            Lighting.OutdoorAmbient = base.OutdoorAmbient:Lerp(tint, strength)
            Lighting.ColorShift_Top = base.ColorShiftTop:Lerp(color, 0.78)
            Lighting.ColorShift_Bottom = base.ColorShiftBottom:Lerp(color, 0.62)
        end
        applyStrongDecorTint(color)
    end

    local function clearSkyColor()
        local Lighting = game:GetService("Lighting")
        if State._skyEnvBackup then
            Lighting.Ambient = State._skyEnvBackup.Ambient
            Lighting.OutdoorAmbient = State._skyEnvBackup.OutdoorAmbient
            Lighting.ColorShift_Top = State._skyEnvBackup.ColorShiftTop
            Lighting.ColorShift_Bottom = State._skyEnvBackup.ColorShiftBottom
            State._skyEnvBackup = nil
        end
        local fx = Lighting:FindFirstChild("YM_TOOL_DecorTint")
        if fx then fx:Destroy() end
        local tint = Lighting:FindFirstChild("YM_TOOL_SkyTint")
        if tint then tint:Destroy() end
        State._skyTint = nil
    end
    local function stopSkyRGB()
        if skyRGBConnection then skyRGBConnection:Disconnect(); skyRGBConnection = nil end
    end
    local function startSkyRGB()
        stopSkyRGB()
        State.skyRGB = true
        backupSkyEnvironment()
        skyRGBConnection = RunService.RenderStepped:Connect(function()
            if State.skyRGB then
                local Lighting = game:GetService("Lighting")
                local c = Color3.fromHSV((os.clock() * 0.16) % 1, 0.95, 1)
                local base = State._skyEnvBackup
                if base then
                    local strength = 0.58
                    local tint = Color3.new(1,1,1):Lerp(c, strength)
                    Lighting.Ambient = base.Ambient:Lerp(tint, strength)
                    Lighting.OutdoorAmbient = base.OutdoorAmbient:Lerp(tint, strength)
                    Lighting.ColorShift_Top = base.ColorShiftTop:Lerp(c, 0.78)
                    Lighting.ColorShift_Bottom = base.ColorShiftBottom:Lerp(c, 0.62)
                end
                applyStrongDecorTint(c)
            end
        end)
    end
    local function clearSkyEffects()
        local Lighting = game:GetService("Lighting")
        local tint = Lighting:FindFirstChild("YM_TOOL_SkyTint")
        if tint then tint:Destroy() end
        local atmosphere = Lighting:FindFirstChild("YM_TOOL_SkyAtmosphere")
        if atmosphere then atmosphere:Destroy() end
        local fx = Lighting:FindFirstChild("YM_TOOL_DecorTint")
        if fx then fx:Destroy() end
    end
    local function openColorPicker(titleText, initialColor, callback)
        closeModal(); pickerCallback = callback
        local current = initialColor or Color3.new(1,0,0)
        local h, ss, v = Color3.toHSV(current)
        local f = Instance.new("Frame"); f.Name = "YM_ColorPicker"; f.Size = UDim2.fromOffset(350, 330)
        f.Position = UDim2.new(0.5, -175, 0.5, -165); f.BackgroundColor3 = Color3.fromRGB(8,8,10); f.ZIndex = 300; f.Parent = ScreenGui
        Instance.new("UICorner", f).CornerRadius = UDim.new(0,10); local fs=Instance.new("UIStroke",f); fs.Color=State.primary; fs.Thickness=1.5
        activeModal=f
        local head=Instance.new("TextLabel"); head.Size=UDim2.new(1,-48,0,42); head.BackgroundColor3=blend(State.primary,0.75); head.Text=titleText; head.TextColor3=Color3.new(1,1,1); head.Font=Enum.Font.GothamBlack; head.TextSize=14; head.ZIndex=301; head.Parent=f; Instance.new("UICorner",head).CornerRadius=UDim.new(0,10); dragify(f,head)
        local close=Instance.new("TextButton"); close.Size=UDim2.fromOffset(42,42); close.Position=UDim2.new(1,-42,0,0); close.Text="X"; close.TextColor3=Color3.new(1,1,1); close.BackgroundColor3=blend(State.primary,0.35); close.ZIndex=302; close.Parent=f; Instance.new("UICorner",close).CornerRadius=UDim.new(0,10); close.MouseButton1Click:Connect(closeModal)
        local sv=Instance.new("Frame"); sv.Size=UDim2.fromOffset(235,190); sv.Position=UDim2.fromOffset(16,58); sv.BorderSizePixel=0; sv.BackgroundColor3=Color3.fromHSV(h,1,1); sv.ZIndex=301; sv.Parent=f
        local w=Instance.new("Frame"); w.Size=UDim2.fromScale(1,1); w.BackgroundColor3=Color3.new(1,1,1); w.ZIndex=302; w.Parent=sv; local wg=Instance.new("UIGradient",w); wg.Transparency=NumberSequence.new{NumberSequenceKeypoint.new(0,0),NumberSequenceKeypoint.new(1,1)}
        local b=Instance.new("Frame"); b.Size=UDim2.fromScale(1,1); b.BackgroundColor3=Color3.new(0,0,0); b.ZIndex=303; b.Parent=sv; local bg=Instance.new("UIGradient",b); bg.Transparency=NumberSequence.new{NumberSequenceKeypoint.new(0,1),NumberSequenceKeypoint.new(1,0)}; bg.Rotation=90
        local hue=Instance.new("Frame"); hue.Size=UDim2.fromOffset(26,190); hue.Position=UDim2.fromOffset(264,58); hue.BorderSizePixel=0; hue.ZIndex=301; hue.Parent=f
        local hg=Instance.new("UIGradient",hue); hg.Color=ColorSequence.new{ColorSequenceKeypoint.new(0,Color3.fromRGB(255,0,0)),ColorSequenceKeypoint.new(.17,Color3.fromRGB(255,255,0)),ColorSequenceKeypoint.new(.33,Color3.fromRGB(0,255,0)),ColorSequenceKeypoint.new(.5,Color3.fromRGB(0,255,255)),ColorSequenceKeypoint.new(.67,Color3.fromRGB(0,0,255)),ColorSequenceKeypoint.new(.83,Color3.fromRGB(255,0,255)),ColorSequenceKeypoint.new(1,Color3.fromRGB(255,0,0))}; hg.Rotation=90
        local svMarker=Instance.new("Frame"); svMarker.Name="SVIndicator"; svMarker.Size=UDim2.fromOffset(10,10); svMarker.AnchorPoint=Vector2.new(0.5,0.5); svMarker.BackgroundTransparency=1; svMarker.BorderSizePixel=0; svMarker.ZIndex=305; svMarker.Parent=sv
        local svRing=Instance.new("UIStroke",svMarker); svRing.Thickness=2; svRing.Color=Color3.new(1,1,1)
        Instance.new("UICorner",svMarker).CornerRadius=UDim.new(1,0)
        local hueMarker=Instance.new("Frame"); hueMarker.Name="HueIndicator"; hueMarker.Size=UDim2.new(1,6,0,4); hueMarker.AnchorPoint=Vector2.new(0.5,0.5); hueMarker.BackgroundColor3=Color3.new(1,1,1); hueMarker.BorderSizePixel=0; hueMarker.ZIndex=305; hueMarker.Parent=hue
        Instance.new("UICorner",hueMarker).CornerRadius=UDim.new(0,2)
        local preview=Instance.new("Frame"); preview.Size=UDim2.fromOffset(274,28); preview.Position=UDim2.fromOffset(16,258); preview.BackgroundColor3=current; preview.ZIndex=301; preview.Parent=f; Instance.new("UICorner",preview).CornerRadius=UDim.new(0,6)
        local function updateSV(pos)
            local ap, sz = sv.AbsolutePosition, sv.AbsoluteSize; ss=math.clamp((pos.X-ap.X)/sz.X,0,1); v=1-math.clamp((pos.Y-ap.Y)/sz.Y,0,1); current=Color3.fromHSV(h,ss,v); sv.BackgroundColor3=Color3.fromHSV(h,1,1); preview.BackgroundColor3=current; svMarker.Position=UDim2.new(ss,0,1-v,0)
        end
        local function updateHue(pos)
            local ap, sz = hue.AbsolutePosition, hue.AbsoluteSize; h=math.clamp((pos.Y-ap.Y)/sz.Y,0,1); current=Color3.fromHSV(h,ss,v); sv.BackgroundColor3=Color3.fromHSV(h,1,1); preview.BackgroundColor3=current; svMarker.Position=UDim2.new(ss,0,1-v,0)
        end
        svMarker.Position=UDim2.new(ss,0,1-v,0); hueMarker.Position=UDim2.new(0.5,0,h,0)
        local mode=nil
        sv.InputBegan:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 or i.UserInputType==Enum.UserInputType.Touch then mode="sv"; updateSV(i.Position) end end)
        hue.InputBegan:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 or i.UserInputType==Enum.UserInputType.Touch then mode="hue"; updateHue(i.Position) end end)
        UserInputService.InputChanged:Connect(function(i) if not activeModal or activeModal~=f or not mode then return end; if i.UserInputType==Enum.UserInputType.MouseMovement or i.UserInputType==Enum.UserInputType.Touch then if mode=="sv" then updateSV(i.Position) else updateHue(i.Position) end end end)
        UserInputService.InputEnded:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 or i.UserInputType==Enum.UserInputType.Touch then mode=nil end end)
        local apply=Instance.new("TextButton"); apply.Size=UDim2.fromOffset(274,34); apply.Position=UDim2.fromOffset(16,294); apply.BackgroundColor3=State.primary; apply.Text="APPLIQUER"; apply.TextColor3=Color3.new(1,1,1); apply.Font=Enum.Font.GothamBold; apply.ZIndex=302; apply.Parent=f; Instance.new("UICorner",apply).CornerRadius=UDim.new(0,6)
        apply.MouseButton1Click:Connect(function() if pickerCallback then pickerCallback(current) end; closeModal() end)
    end

    local function askImageId(titleText, currentValue, callback)
        closeModal(); local f=Instance.new("Frame"); f.Size=UDim2.fromOffset(360,175); f.Position=UDim2.new(.5,-180,.5,-88); f.BackgroundColor3=Color3.fromRGB(8,8,10); f.ZIndex=310; f.Parent=ScreenGui; Instance.new("UICorner",f).CornerRadius=UDim.new(0,10); Instance.new("UIStroke",f).Color=State.primary; activeModal=f
        local t=Instance.new("TextLabel"); t.Size=UDim2.new(1,-48,0,42); t.BackgroundColor3=blend(State.primary,.75); t.Text=titleText; t.TextColor3=Color3.new(1,1,1); t.Font=Enum.Font.GothamBlack; t.TextSize=13; t.ZIndex=311; t.Parent=f; Instance.new("UICorner",t).CornerRadius=UDim.new(0,10); dragify(f,t)
        local x=Instance.new("TextButton"); x.Size=UDim2.fromOffset(42,42); x.Position=UDim2.new(1,-42,0,0); x.Text="X"; x.BackgroundColor3=blend(State.primary,.35); x.TextColor3=Color3.new(1,1,1); x.ZIndex=312; x.Parent=f; x.MouseButton1Click:Connect(closeModal)
        local box=Instance.new("TextBox"); box.Size=UDim2.new(1,-30,0,38); box.Position=UDim2.fromOffset(15,55); box.Text=tostring(currentValue or ""):gsub("rbxassetid://",""); box.PlaceholderText="Exemple : 123456789"; box.TextColor3=Color3.new(1,1,1); box.BackgroundColor3=blend(State.primary,.78); box.Font=Enum.Font.Gotham; box.TextSize=13; box.ZIndex=311; box.Parent=f; Instance.new("UICorner",box).CornerRadius=UDim.new(0,6)
        local ok=Instance.new("TextButton"); ok.Size=UDim2.new(1,-30,0,34); ok.Position=UDim2.fromOffset(15,108); ok.BackgroundColor3=State.primary; ok.Text="APPLIQUER"; ok.TextColor3=Color3.new(1,1,1); ok.Font=Enum.Font.GothamBold; ok.ZIndex=311; ok.Parent=f; Instance.new("UICorner",ok).CornerRadius=UDim.new(0,6); ok.MouseButton1Click:Connect(function() if callback(box.Text) then notify("Image appliquée.",true) end; closeModal() end)
    end

    local function serialize()
        return {primary={State.primary.R,State.primary.G,State.primary.B},transparency=State.transparency,background=State.background,buttonImage=State.buttonImage,skyRGB=State.skyRGB,skyColor={State.skyColor.R,State.skyColor.G,State.skyColor.B},skyImage=State.skyImage}
    end
    local function savePreset(name)
        name = tostring(name or ""):gsub("[^%w_%-]", "_"); if name=="" then name="Preset_"..os.time() end
        local data=serialize(); local ok,json=pcall(function() return HttpService:JSONEncode(data) end); if not ok then notify("Impossible de sauvegarder le thème.",false); return end
        State._memoryPresets[name]=json
        local wrote=false
        if type(makefolder)=="function" then pcall(function() makefolder(presetFolder) end) end
        if type(writefile)=="function" then wrote=pcall(function() writefile(presetFolder.."/"..name..".json",json) end) end
        notify("Thème sauvegardé : "..name..(wrote and " ✓" or " ✓ (mémoire)"),true)
    end
    local function applyPresetData(data)
        if data.primary then applyPrimaryColor(Color3.new(data.primary[1] or 1,data.primary[2] or 0,data.primary[3] or 0)) end
        if data.transparency then applyTransparency(data.transparency) end
        if data.background then setThemeBackground(data.background) end
        if data.buttonImage then setThemeButtonImage(data.buttonImage) end
        State.skyRGB=data.skyRGB==true
        if data.skyColor then applySkyColor(Color3.new(data.skyColor[1] or 1,data.skyColor[2] or 0,data.skyColor[3] or 0)) end
        if not State.skyRGB and data.skyColor == nil then clearSkyEffects() end
        if data.skyImage then
            local sky=getSky(); State.skyImage=data.skyImage
            sky.SkyboxBk=data.skyImage; sky.SkyboxDn=data.skyImage; sky.SkyboxFt=data.skyImage; sky.SkyboxLf=data.skyImage; sky.SkyboxRt=data.skyImage; sky.SkyboxUp=data.skyImage
        end
        if State.skyRGB then startSkyRGB() else stopSkyRGB() end
    end
    local function loadPreset(name)
        local json=State._memoryPresets[name]
        if not json and type(readfile)=="function" then pcall(function() json=readfile(presetFolder.."/"..name..".json") end) end
        if not json then notify("Preset introuvable.",false); return end
        local ok,data=pcall(function() return HttpService:JSONDecode(json) end); if ok and type(data)=="table" then applyPresetData(data); notify("Preset chargé : "..name,true) else notify("Preset invalide.",false) end
    end
    local function listPresets()
        local out={}; for n in pairs(State._memoryPresets) do table.insert(out,n) end
        if type(listfiles)=="function" then
            local ok,files=pcall(function() return listfiles(presetFolder) end)
            if ok and type(files)=="table" then for _,path in ipairs(files) do local n=tostring(path):match("([^/\\]+)%.json$"); if n then local seen=false; for _,x in ipairs(out) do if x==n then seen=true end end; if not seen then table.insert(out,n) end end end end
        end
        table.sort(out); return out
    end
    local function openPresetWindow()
        closeModal(); local f=Instance.new("Frame"); f.Size=UDim2.fromOffset(430,390); f.Position=UDim2.new(.5,-215,.5,-195); f.BackgroundColor3=Color3.fromRGB(8,8,10); f.ZIndex=320; f.Parent=ScreenGui; Instance.new("UICorner",f).CornerRadius=UDim.new(0,10); Instance.new("UIStroke",f).Color=State.primary; activeModal=f
        local t=Instance.new("TextLabel"); t.Size=UDim2.new(1,-48,0,44); t.BackgroundColor3=blend(State.primary,.75); t.Text="PRESETS DU THEME"; t.TextColor3=Color3.new(1,1,1); t.Font=Enum.Font.GothamBlack; t.TextSize=15; t.ZIndex=321; t.Parent=f; Instance.new("UICorner",t).CornerRadius=UDim.new(0,10); dragify(f,t)
        local x=Instance.new("TextButton"); x.Size=UDim2.fromOffset(42,42); x.Position=UDim2.new(1,-42,0,0); x.Text="X"; x.BackgroundColor3=blend(State.primary,.35); x.TextColor3=Color3.new(1,1,1); x.ZIndex=322; x.Parent=f; x.MouseButton1Click:Connect(closeModal)
        local list=Instance.new("ScrollingFrame"); list.Size=UDim2.new(1,-30,1,-100); list.Position=UDim2.fromOffset(15,55); list.BackgroundColor3=blend(State.primary,.90); list.ScrollBarImageColor3=State.primary; list.ScrollBarThickness=5; list.ZIndex=321; list.Parent=f; Instance.new("UICorner",list).CornerRadius=UDim.new(0,7); local layout=Instance.new("UIListLayout",list); layout.Padding=UDim.new(0,6)
        local names=listPresets()
        if #names==0 then local empty=Instance.new("TextLabel"); empty.Size=UDim2.new(1,-10,0,60); empty.BackgroundTransparency=1; empty.Text="Aucun preset pour le moment.\nSauvegarde un thème pour le créer ici."; empty.TextColor3=Color3.fromRGB(210,210,210); empty.Font=Enum.Font.Gotham; empty.TextSize=12; empty.ZIndex=322; empty.Parent=list
        else for _,name in ipairs(names) do local b=Instance.new("TextButton"); b.Size=UDim2.new(1,-10,0,40); b.BackgroundColor3=blend(State.primary,.72); b.Text="📂  "..name; b.TextColor3=Color3.new(1,1,1); b.Font=Enum.Font.GothamBold; b.TextSize=12; b.ZIndex=322; b.Parent=list; Instance.new("UICorner",b).CornerRadius=UDim.new(0,6); b.MouseButton1Click:Connect(function() loadPreset(name); closeModal() end) end end
        local save=Instance.new("TextButton"); save.Size=UDim2.new(1,-30,0,34); save.Position=UDim2.new(0,15,1,-42); save.BackgroundColor3=State.primary; save.Text="NOUVEAU PRESET"; save.TextColor3=Color3.new(1,1,1); save.Font=Enum.Font.GothamBold; save.ZIndex=322; save.Parent=f; Instance.new("UICorner",save).CornerRadius=UDim.new(0,6)
        save.MouseButton1Click:Connect(function()
            local box=Instance.new("TextBox"); box.Size=UDim2.new(1,-80,0,34); box.Position=UDim2.new(0,15,1,-42); box.BackgroundColor3=blend(State.primary,.78); box.Text="MonTheme"; box.TextColor3=Color3.new(1,1,1); box.ZIndex=323; box.Parent=f; Instance.new("UICorner",box).CornerRadius=UDim.new(0,6); save.Visible=false
            local ok=Instance.new("TextButton"); ok.Size=UDim2.fromOffset(50,34); ok.Position=UDim2.new(1,-65,1,-42); ok.Text="OK"; ok.BackgroundColor3=State.primary; ok.TextColor3=Color3.new(1,1,1); ok.ZIndex=323; ok.Parent=f; Instance.new("UICorner",ok).CornerRadius=UDim.new(0,6); ok.MouseButton1Click:Connect(function() savePreset(box.Text); closeModal() end)
        end)
    end

    local function applySkinColor(target, color)
        local char=player.Character; if not char then return end
        if target=="ALL SKIN" then
            for _,obj in ipairs(char:GetDescendants()) do if obj:IsA("BasePart") and not obj:IsA("HumanoidRootPart") then obj.Color=color end end
            return
        end
        if target=="OBJET EN MAIN" then local tool=char:FindFirstChildOfClass("Tool"); local h=tool and tool:FindFirstChild("Handle"); if h and h:IsA("BasePart") then h.Color=color end; return end
        local aliases={Head={"Head"},Torso={"Torso","UpperTorso","LowerTorso"},["Left Arm"]={"Left Arm","LeftUpperArm","LeftLowerArm","LeftHand"},["Right Arm"]={"Right Arm","RightUpperArm","RightLowerArm","RightHand"},["Left Leg"]={"Left Leg","LeftUpperLeg","LeftLowerLeg","LeftFoot"},["Right Leg"]={"Right Leg","RightUpperLeg","RightLowerLeg","RightFoot"}}
        for _,n in ipairs(aliases[target] or {}) do local p=char:FindFirstChild(n,true); if p and p:IsA("BasePart") then p.Color=color end end
    end
    local function openSkinEditor()
        closeModal(); local f=Instance.new("Frame"); f.Size=UDim2.fromOffset(520,430); f.Position=UDim2.new(.5,-260,.5,-215); f.BackgroundColor3=Color3.fromRGB(8,8,10); f.ZIndex=340; f.Parent=ScreenGui; Instance.new("UICorner",f).CornerRadius=UDim.new(0,10); Instance.new("UIStroke",f).Color=State.primary; activeModal=f
        local t=Instance.new("TextLabel"); t.Size=UDim2.new(1,-48,0,42); t.BackgroundColor3=blend(State.primary,.75); t.Text="SKIN EDITOR"; t.TextColor3=Color3.new(1,1,1); t.Font=Enum.Font.GothamBlack; t.TextSize=15; t.ZIndex=341; t.Parent=f; Instance.new("UICorner",t).CornerRadius=UDim.new(0,10); dragify(f,t)
        local x=Instance.new("TextButton"); x.Size=UDim2.fromOffset(42,42); x.Position=UDim2.new(1,-42,0,0); x.Text="X"; x.BackgroundColor3=blend(State.primary,.35); x.TextColor3=Color3.new(1,1,1); x.ZIndex=342; x.Parent=f; x.MouseButton1Click:Connect(closeModal)
        local selected="ALL SKIN"; local parts={"ALL SKIN","Head","Torso","Left Arm","Right Arm","Left Leg","Right Leg","OBJET EN MAIN"}
        local list=Instance.new("ScrollingFrame"); list.Size=UDim2.fromOffset(180,345); list.Position=UDim2.fromOffset(12,55); list.BackgroundColor3=blend(State.primary,.90); list.ScrollBarImageColor3=State.primary; list.ZIndex=341; list.Parent=f; Instance.new("UICorner",list).CornerRadius=UDim.new(0,6); local ll=Instance.new("UIListLayout",list); ll.Padding=UDim.new(0,5)
        for _,name in ipairs(parts) do local b=Instance.new("TextButton"); b.Size=UDim2.new(1,-8,0,36); b.BackgroundColor3=blend(State.primary,.72); b.Text=name; b.TextColor3=Color3.new(1,1,1); b.Font=Enum.Font.GothamBold; b.TextSize=11; b.ZIndex=342; b.Parent=list; Instance.new("UICorner",b).CornerRadius=UDim.new(0,6); b.MouseButton1Click:Connect(function() selected=name end) end
        local info=Instance.new("TextLabel"); info.Size=UDim2.new(1,-215,0,70); info.Position=UDim2.fromOffset(200,65); info.BackgroundTransparency=1; info.Text="Sélectionne une partie puis choisis une couleur.\nALL SKIN applique la couleur à toutes les parties visibles."; info.TextColor3=Color3.fromRGB(220,220,220); info.Font=Enum.Font.Gotham; info.TextSize=12; info.TextWrapped=true; info.ZIndex=341; info.Parent=f
        local pick=Instance.new("TextButton"); pick.Size=UDim2.new(1,-215,0,40); pick.Position=UDim2.fromOffset(200,350); pick.BackgroundColor3=State.primary; pick.Text="CHOISIR LA COULEUR"; pick.TextColor3=Color3.new(1,1,1); pick.Font=Enum.Font.GothamBold; pick.ZIndex=342; pick.Parent=f; Instance.new("UICorner",pick).CornerRadius=UDim.new(0,6); pick.MouseButton1Click:Connect(function() openColorPicker("SKIN EDITOR • "..selected,Color3.fromRGB(255,0,0),function(c) applySkinColor(selected,c) end) end)
    end
    local function makeLabel(page,text)
        local l=Instance.new("TextLabel"); l.Size=UDim2.new(1,-10,0,28); l.BackgroundTransparency=1; l.Text=text; l.TextColor3=State.primary; l.Font=Enum.Font.GothamBlack; l.TextSize=13; l.TextXAlignment=Enum.TextXAlignment.Left; l.ZIndex=30; l.Parent=page
    end
    local function makeAction(page,text,callback)
        local b=Instance.new("TextButton"); b.Size=UDim2.new(1,-10,0,38); b.BackgroundColor3=blend(State.primary,.72); b.BackgroundTransparency=.10; b.Text=text; b.TextColor3=Color3.new(1,1,1); b.Font=Enum.Font.GothamBold; b.TextSize=12; b.AutoButtonColor=false; b.ZIndex=30; b.Parent=page; Instance.new("UICorner",b).CornerRadius=UDim.new(0,6); local st=Instance.new("UIStroke",b); st.Color=State.primary; b.MouseButton1Click:Connect(callback); return b
    end

    local page=pages["THEME EDITOR"]
    makeLabel(page,"PERSONNALISATION")
    makeAction(page,"🎨 Couleur principale",function() openColorPicker("COULEUR PRINCIPALE",State.primary,applyPrimaryColor) end)
    makeAction(page,"🌑 Transparence",function()
        closeModal(); local f=Instance.new("Frame"); f.Size=UDim2.fromOffset(340,170); f.Position=UDim2.new(.5,-170,.5,-85); f.BackgroundColor3=Color3.fromRGB(8,8,10); f.ZIndex=310; f.Parent=ScreenGui; Instance.new("UICorner",f).CornerRadius=UDim.new(0,10); Instance.new("UIStroke",f).Color=State.primary; activeModal=f
        local t=Instance.new("TextLabel"); t.Size=UDim2.new(1,-48,0,40); t.BackgroundColor3=blend(State.primary,.75); t.Text="TRANSPARENCE"; t.TextColor3=Color3.new(1,1,1); t.Font=Enum.Font.GothamBlack; t.ZIndex=311; t.Parent=f; Instance.new("UICorner",t).CornerRadius=UDim.new(0,10); dragify(f,t)
        local box=Instance.new("TextBox"); box.Size=UDim2.new(1,-30,0,34); box.Position=UDim2.fromOffset(15,52); box.Text=tostring(State.transparency); box.TextColor3=Color3.new(1,1,1); box.BackgroundColor3=blend(State.primary,.78); box.ZIndex=311; box.Parent=f
        local ok=Instance.new("TextButton"); ok.Size=UDim2.new(1,-30,0,34); ok.Position=UDim2.fromOffset(15,102); ok.Text="APPLIQUER"; ok.BackgroundColor3=State.primary; ok.TextColor3=Color3.new(1,1,1); ok.ZIndex=311; ok.Parent=f; ok.MouseButton1Click:Connect(function() applyTransparency(box.Text); closeModal() end)
    end)
    makeAction(page,"🖼️ Background personnalisé",function() askImageId("BACKGROUND • ROBLOX IMAGE ID",State.background,function(id) return setThemeBackground(id) end) end)
    makeAction(page,"🖼️ Image des boutons",function() askImageId("BOUTONS • ROBLOX IMAGE ID",State.buttonImage,function(id) return setThemeButtonImage(id) end) end)
    makeAction(page,"💾 Sauvegarder le thème",function()
        closeModal(); local f=Instance.new("Frame"); f.Size=UDim2.fromOffset(360,175); f.Position=UDim2.new(.5,-180,.5,-88); f.BackgroundColor3=Color3.fromRGB(8,8,10); f.ZIndex=310; f.Parent=ScreenGui; Instance.new("UICorner",f).CornerRadius=UDim.new(0,10); Instance.new("UIStroke",f).Color=State.primary; activeModal=f
        local t=Instance.new("TextLabel"); t.Size=UDim2.new(1,-48,0,40); t.BackgroundColor3=blend(State.primary,.75); t.Text="SAUVEGARDER LE THÈME"; t.TextColor3=Color3.new(1,1,1); t.Font=Enum.Font.GothamBlack; t.ZIndex=311; t.Parent=f; dragify(f,t)
        local box=Instance.new("TextBox"); box.Size=UDim2.new(1,-30,0,34); box.Position=UDim2.fromOffset(15,52); box.Text="MonTheme"; box.TextColor3=Color3.new(1,1,1); box.BackgroundColor3=blend(State.primary,.78); box.ZIndex=311; box.Parent=f
        local ok=Instance.new("TextButton"); ok.Size=UDim2.new(1,-30,0,34); ok.Position=UDim2.fromOffset(15,102); ok.Text="SAUVEGARDER"; ok.BackgroundColor3=State.primary; ok.TextColor3=Color3.new(1,1,1); ok.ZIndex=311; ok.Parent=f; ok.MouseButton1Click:Connect(function() savePreset(box.Text); closeModal() end)
    end)
    makeAction(page,"📂 Charger un preset",openPresetWindow)
    makeLabel(page,"CIEL")
    makeAction(page,"🎨 Couleur du ciel",function() openColorPicker("COULEUR DU CIEL",State.skyColor,applySkyColor) end)
    makeAction(page,"🌈 RGB du ciel",function()
        if State.skyRGB then
            stopSkyRGB(); State.skyRGB=false; clearSkyColor()
        else
            startSkyRGB()
        end
    end)
    makeAction(page,"🌌 IMAGE DU CIEL",function() askImageId("IMAGE DU CIEL • ROBLOX IMAGE ID",nil,function(id)
        local u=uri(id); if not u then return false end
        local sky=getSky()
        State._skyObject=sky
        sky.SkyboxBk=u; sky.SkyboxDn=u; sky.SkyboxFt=u; sky.SkyboxLf=u; sky.SkyboxRt=u; sky.SkyboxUp=u
        State.skyImage=u
        return true
    end) end)
    makeAction(page,"🗑️ Supprimer l'image du ciel",function()
        local Lighting=game:GetService("Lighting")
        local sky=State._skyObject
        if sky and sky.Parent then
            if State._skyWasCreated then
                sky:Destroy()
            elseif State._skyBackup then
                sky.SkyboxBk=State._skyBackup[1] or ""; sky.SkyboxDn=State._skyBackup[2] or ""; sky.SkyboxFt=State._skyBackup[3] or ""
                sky.SkyboxLf=State._skyBackup[4] or ""; sky.SkyboxRt=State._skyBackup[5] or ""; sky.SkyboxUp=State._skyBackup[6] or ""
            end
        end
        -- Safety fallback: remove any YM_TOOL-created Sky left behind.
        local ymSky=Lighting:FindFirstChild("YM_TOOL_Sky")
        if ymSky and ymSky:IsA("Sky") then ymSky:Destroy() end
        State.skyImage=nil; State._skyBackup=nil; State._skyWasCreated=false; State._skyName=nil; State._skyObject=nil
        notify("Image du ciel supprimée.",true)
    end)
    makeLabel(page,"SKIN EDITOR")
    makeAction(page,"🎭 Ouvrir le SKIN EDITOR",openSkinEditor)
    return State
end

local function loadMainScript()
	if scriptLoaded then return end
	scriptLoaded = true
	PassGui:Destroy()
	protect()

	
	local flying, flySpeed, walkSpeed = false, 50, 16
	local godmode, invisible, noclip, rgb = false, false, false, false
	local glue, aimbot, esp = false, false, false
	local aimScope = false
	local aiming = false
	local spinning, spinSpeed = false, 50
	local spinning90, spinSpeed90 = false, 5000
	local moveObjects = false
	local clickTP, killAura, bringAll = false, false, false
	local infiniteJump, noFallDamage, antiAFK, ragdoll = false, false, false, false
	local skeletonESP, nameGlitch = false, false
	local fakeLagTP, fakeLagAngles = false, false
	local superForce = false
	local autoClick = false
	local forcePower = 2800
	local jumpPower = 50
	local fpsCap = 0
	local fpsCounterEnabled = true
	local crosshairEnabled = true

	local FPSGui = Instance.new("ScreenGui")
	FPSGui.Name = "YM_FPS_COUNTER"
	FPSGui.ResetOnSpawn = false
	FPSGui.Parent = player:WaitForChild("PlayerGui")

	local FPSLabel = Instance.new("TextLabel")
	FPSLabel.Name = "FPSCounter"
	FPSLabel.Size = UDim2.new(0, 100, 0, 28)
	FPSLabel.Position = UDim2.new(0, 8, 0, 70)
	FPSLabel.BackgroundTransparency = 1
	FPSLabel.Text = "0 FPS"
	FPSLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	FPSLabel.Font = Enum.Font.GothamBold
	FPSLabel.TextSize = 16
	FPSLabel.TextXAlignment = Enum.TextXAlignment.Left
	FPSLabel.Active = true
	FPSLabel.Parent = FPSGui

	local fpsDragging, fpsDragStart, fpsStartPos
	FPSLabel.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			fpsDragging = true
			fpsDragStart = input.Position
			fpsStartPos = FPSLabel.Position
			input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then fpsDragging = false end
			end)
		end
	end)
	UserInputService.InputChanged:Connect(function(input)
		if fpsDragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
			local delta = input.Position - fpsDragStart
			FPSLabel.Position = UDim2.new(fpsStartPos.X.Scale, fpsStartPos.X.Offset + delta.X, fpsStartPos.Y.Scale, fpsStartPos.Y.Offset + delta.Y)
		end
	end)

	local function applyFPSCap()
		if type(setfpscap) == "function" then
			pcall(function() setfpscap(fpsCap) end)
		end
	end
	applyFPSCap()

	task.spawn(function()
		local last = tick()
		local frames = 0
		while FPSGui.Parent do
			RunService.RenderStepped:Wait()
			frames += 1
			local now = tick()
			if now - last >= 0.5 then
				FPSLabel.Text = math.floor(frames / (now - last) + 0.5) .. " FPS"
				frames = 0
				last = now
			end
		end
	end)

	local bodyGyro, bodyVelocity
	local rgbConnection, glueConnection, spinConnection, spin90Connection
	local moveConnection, clickTPConnection, killAuraConnection
	local bringConnection, jumpConnection, fallConnection, antiAFKConnection
	local skeletonConnection, nameGlitchConnection
	local fakeLagTPConnection, fakeLagAnglesConnection
	local forceConnections = {}
	local autoClickConnection
	local autoClickHeld = false
	local gluedTarget, selectedPart
	local guiVisible = true
	local highlights = {}
	local ragdollConstraints = {}
	local skeletonDrawings = {}
	local nameGlitchBillboard = nil
	local boxESP = false
	local boxESPConnection = nil
	local boxESPObjects = {}
	local teamCheckEnabled = false
	local visibilityCheckEnabled = false
	local fovEnabled = false
	local fovRadius = 150
	local debugVisible = false

	
	local bigHeadEnabled = false
	local tinyCharacterEnabled = false
	local headlessEnabled = false
	local characterVisualBackup = {}

	local function cacheCharacterVisuals(char)
		if characterVisualBackup.char == char then return end
		characterVisualBackup = {char = char, parts = {}, scales = {}}
		local head = char:FindFirstChild("Head")
		if head and head:IsA("BasePart") then
			characterVisualBackup.parts.HeadSize = head.Size
			characterVisualBackup.parts.HeadTransparency = head.Transparency
			for _, obj in ipairs(head:GetDescendants()) do
				if obj:IsA("Decal") or obj:IsA("Texture") then
					characterVisualBackup.parts[obj] = obj.Transparency
				end
			end
		end
		for _, name in ipairs({"Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}) do
			local part = char:FindFirstChild(name)
			if part and part:IsA("BasePart") then characterVisualBackup.parts[name] = part.Size end
		end
		for _, obj in ipairs(char:GetDescendants()) do
			if obj:IsA("NumberValue") and (obj.Name == "BodyHeightScale" or obj.Name == "BodyWidthScale" or obj.Name == "BodyDepthScale" or obj.Name == "HeadScale") then
				characterVisualBackup.scales[obj.Name] = obj.Value
			end
		end
	end

	local function restoreCharacterVisuals()
		local char = player.Character
		if not char or characterVisualBackup.char ~= char then return end
		local head = char:FindFirstChild("Head")
		if head and characterVisualBackup.parts.HeadSize then
			head.Size = characterVisualBackup.parts.HeadSize
			head.Transparency = characterVisualBackup.parts.HeadTransparency or 0
			for _, obj in ipairs(head:GetDescendants()) do
				if (obj:IsA("Decal") or obj:IsA("Texture")) and characterVisualBackup.parts[obj] ~= nil then
					obj.Transparency = characterVisualBackup.parts[obj]
				end
			end
		end
		for _, name in ipairs({"Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}) do
			local part = char:FindFirstChild(name)
			local original = characterVisualBackup.parts[name]
			if part and original then part.Size = original end
		end
		for name, value in pairs(characterVisualBackup.scales) do
			local obj = char:FindFirstChild(name, true)
			if obj and obj:IsA("NumberValue") then obj.Value = value end
		end
	end

	local function updateCharacterVisuals()
		local char = player.Character
		if not char then return end
		cacheCharacterVisuals(char)
		restoreCharacterVisuals()
		local head = char:FindFirstChild("Head")
		local hum = char:FindFirstChildOfClass("Humanoid")
		if bigHeadEnabled and head and head:IsA("BasePart") then
			head.Size = characterVisualBackup.parts.HeadSize * 2.5
		end
		if tinyCharacterEnabled then
			for _, name in ipairs({"BodyHeightScale", "BodyWidthScale", "BodyDepthScale", "HeadScale"}) do
				local obj = char:FindFirstChild(name, true)
				if obj and obj:IsA("NumberValue") then obj.Value = (characterVisualBackup.scales[name] or 1) * 0.35 end
			end
			if not char:FindFirstChild("BodyHeightScale", true) then
				for _, name in ipairs({"Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}) do
					local part = char:FindFirstChild(name)
					if part and part:IsA("BasePart") then
						local original = characterVisualBackup.parts[name] or part.Size
						characterVisualBackup.parts[name] = original
						part.Size = original * 0.35
					end
				end
			end
		end
		if headlessEnabled and head then
			head.Transparency = 1
			for _, obj in ipairs(head:GetDescendants()) do
				if obj:IsA("Decal") or obj:IsA("Texture") then obj.Transparency = 1 end
			end
		end
	end

	
	local waypointSlots = {}
	for i = 1, 6 do waypointSlots[i] = {name = "Slot " .. i, cframe = nil} end
	local WaypointFrame

	
	local CrosshairGui = Instance.new("ScreenGui")
	CrosshairGui.Name = "YM_Crosshair"
	CrosshairGui.ResetOnSpawn = false
	CrosshairGui.IgnoreGuiInset = true
	CrosshairGui.Parent = player:WaitForChild("PlayerGui")
	local CrosshairDot = Instance.new("Frame")
	CrosshairDot.Name = "RGBDot"
	CrosshairDot.Size = UDim2.fromOffset(5, 5)
	CrosshairDot.AnchorPoint = Vector2.new(0.5, 0.5)
	CrosshairDot.Position = UDim2.new(0.5, 0, 0.5, 0)
	CrosshairDot.BorderSizePixel = 0
	CrosshairDot.ZIndex = 100
	CrosshairDot.Visible = crosshairEnabled
	CrosshairDot.Parent = CrosshairGui
	Instance.new("UICorner", CrosshairDot).CornerRadius = UDim.new(1, 0)
	task.spawn(function()
		while CrosshairGui.Parent do
			CrosshairDot.Visible = crosshairEnabled
			if crosshairEnabled then CrosshairDot.BackgroundColor3 = Color3.fromHSV((tick() * 0.25) % 1, 1, 1) end
			RunService.RenderStepped:Wait()
		end
	end)



	
	local VisibilityESP = {}
	local isTeammate
	local isVisibleFromCamera

	local function removeVisibilityESP(plr)
		local obj = VisibilityESP[plr]
		if obj then
			if obj.box then pcall(function() obj.box:Remove() end) end
			VisibilityESP[plr] = nil
		end
	end

	local function createVisibilityESP(plr)
		if plr == player or VisibilityESP[plr] then return end
		local char = plr.Character
		if not char then return end

		
		local highlight = Instance.new("Highlight")
		highlight.Name = "YM_VisibilityHighlight"
		highlight.Adornee = char
		highlight.FillTransparency = 0.35
		highlight.OutlineTransparency = 1
		highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
		highlight.Enabled = visibilityCheckEnabled
		highlight.Parent = char

		VisibilityESP[plr] = {highlight = highlight}
	end

	local function updateVisibilityESP()
		for _, plr in ipairs(Players:GetPlayers()) do
			if plr ~= player and plr.Character and not isTeammate(plr) then
				local char = plr.Character
				local root = char:FindFirstChild("HumanoidRootPart")
				local head = char:FindFirstChild("Head")
				local hum = char:FindFirstChildOfClass("Humanoid")

				if root and head and hum and hum.Health > 0 then
					createVisibilityESP(plr)
					local d = VisibilityESP[plr]
					if d and d.highlight then
						-- Vert = le joueur est visible ; rouge = il est derrière un obstacle.
						local visible = isVisibleFromCamera(root, char)
						d.highlight.FillColor = visible and Color3.fromRGB(40, 255, 80) or Color3.fromRGB(255, 40, 40)
						d.highlight.Enabled = visibilityCheckEnabled
					end
				else
					removeVisibilityESP(plr)
				end
			else
				removeVisibilityESP(plr)
			end
		end
	end

	Players.PlayerRemoving:Connect(removeVisibilityESP)

	RunService.RenderStepped:Connect(function()
		if visibilityCheckEnabled then
			updateVisibilityESP()
		else
			for _, obj in pairs(VisibilityESP) do
				if obj.highlight then obj.highlight.Enabled = false end
			end
		end
	end)

	
	local FOVGui = Instance.new("ScreenGui")
	FOVGui.Name = "YM_FOV"
	FOVGui.IgnoreGuiInset = true
	FOVGui.ResetOnSpawn = false
	FOVGui.Parent = player:WaitForChild("PlayerGui")

	local FOVCircle = Instance.new("Frame")
	FOVCircle.Name = "FOVCircle"
	FOVCircle.AnchorPoint = Vector2.new(0.5, 0.5)
	FOVCircle.Position = UDim2.fromScale(0.5, 0.5)
	FOVCircle.Size = UDim2.fromOffset(fovRadius * 2, fovRadius * 2)
	FOVCircle.BackgroundTransparency = 1
	FOVCircle.Visible = fovEnabled
	FOVCircle.ZIndex = 90
	FOVCircle.Parent = FOVGui
	local fovCorner = Instance.new("UICorner")
	fovCorner.CornerRadius = UDim.new(1, 0)
	fovCorner.Parent = FOVCircle
	local fovStroke = Instance.new("UIStroke")
	fovStroke.Thickness = 1.5
	fovStroke.Parent = FOVCircle

	task.spawn(function()
		while FOVGui.Parent do
			FOVCircle.Visible = fovEnabled
			FOVCircle.Size = UDim2.fromOffset(fovRadius * 2, fovRadius * 2)
			if fovEnabled then
				fovStroke.Color = Color3.fromHSV((tick() * 0.25) % 1, 1, 1)
			end
			RunService.RenderStepped:Wait()
		end
	end)


	local function getChar() return player.Character end
	local function getHumanoid() local c = getChar() return c and c:FindFirstChildOfClass("Humanoid") end
	local function getRoot() local c = getChar() return c and c:FindFirstChild("HumanoidRootPart") end

	-- ========== ANTI-FLING ==========
	-- Protection locale activable depuis FUN.
	-- Si le personnage reçoit une vitesse anormalement élevée,
	-- on coupe ses vitesses linéaire et angulaire.
	local antiFlingEnabled = false
	local antiFlingConnection
	local ANTI_FLING_SPEED = 180
	local ANTI_FLING_ANGULAR = 80

	local function startAntiFling()
		if antiFlingConnection then return end
		antiFlingConnection = RunService.Heartbeat:Connect(function()
			if not antiFlingEnabled then return end
			local char = player.Character
			local root = char and char:FindFirstChild("HumanoidRootPart")
			if not root or not root:IsA("BasePart") then return end

			local velocity = root.AssemblyLinearVelocity
			local angular = root.AssemblyAngularVelocity

			if velocity.Magnitude > ANTI_FLING_SPEED or angular.Magnitude > ANTI_FLING_ANGULAR then
				root.AssemblyLinearVelocity = Vector3.zero
				root.AssemblyAngularVelocity = Vector3.zero
				local hum = char:FindFirstChildOfClass("Humanoid")
				if hum then
					hum:ChangeState(Enum.HumanoidStateType.GettingUp)
				end
			end
		end)
	end

	local function stopAntiFling()
		if antiFlingConnection then
			antiFlingConnection:Disconnect()
			antiFlingConnection = nil
		end
	end

	isTeammate = function(plr)
		if not teamCheckEnabled then return false end
		if player.Team ~= nil and plr.Team ~= nil then
			return player.Team == plr.Team
		end
		return false
	end

	isVisibleFromCamera = function(part, char)
		if not visibilityCheckEnabled then return true end
		local currentCamera = workspace.CurrentCamera
		if not currentCamera or not char then return false end

		local origin = currentCamera.CFrame.Position
		local points = {}

		-- Plusieurs points évitent les faux rouges quand seule la tête est derrière un petit obstacle.
		local head = char:FindFirstChild("Head")
		local root = char:FindFirstChild("HumanoidRootPart")
		local upper = char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso")
		local lower = char:FindFirstChild("LowerTorso")
		local leftArm = char:FindFirstChild("LeftUpperArm") or char:FindFirstChild("Left Arm")
		local rightArm = char:FindFirstChild("RightUpperArm") or char:FindFirstChild("Right Arm")

		for _, obj in ipairs({head, upper, lower, root, leftArm, rightArm, part}) do
			if obj and obj:IsA("BasePart") then
				table.insert(points, obj.Position)
			end
		end

		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = {player.Character, char}
		params.IgnoreWater = true

		
		for _, targetPosition in ipairs(points) do
			local direction = targetPosition - origin
			if direction.Magnitude <= 0.01 then
				return true
			end

			local result = workspace:Raycast(origin, direction, params)
			if result == nil then
				return true
			end
		end

		return false
	end

	local function setWalkSpeed(v)
		walkSpeed = v
		local h = getHumanoid()
		if h then
			h.WalkSpeed = v
			h:SetStateEnabled(Enum.HumanoidStateType.Running, true)
		end
	end

	
	local gameSprintSpeed = nil

	
	local function startFly()
		if flying then return end
		flying = true
		local root, hum = getRoot(), getHumanoid()
		if not root or not hum then return end
		bodyGyro = Instance.new("BodyGyro")
		bodyGyro.P = 9e4
		bodyGyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9)
		bodyGyro.CFrame = root.CFrame
		bodyGyro.Parent = root
		bodyVelocity = Instance.new("BodyVelocity")
		bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9)
		bodyVelocity.Parent = root
		hum.PlatformStand = true
	end
	local function stopFly()
		if not flying then return end
		flying = false
		if bodyGyro then bodyGyro:Destroy() end
		if bodyVelocity then bodyVelocity:Destroy() end
		local hum = getHumanoid()
		if hum then hum.PlatformStand = false end
	end

	local function setInvisible(state)
		local char = getChar()
		if not char then return end
		for _, v in pairs(char:GetDescendants()) do
			if v:IsA("BasePart") then
				v.Transparency = state and 1 or 0
				if state then v.CanCollide = false end
			elseif v:IsA("Decal") or v:IsA("Texture") then
				v.Transparency = state and 1 or 0
			elseif v:IsA("ParticleEmitter") or v:IsA("Trail") or v:IsA("Beam") then
				v.Enabled = not state
			end
		end
	end

	local function startRGB()
		if rgbConnection then rgbConnection:Disconnect() end
		rgbConnection = RunService.Heartbeat:Connect(function()
			if not rgb then return end
			local char = getChar()
			if not char then return end
			local color = Color3.fromHSV((tick() % 5)/5, 1, 1)
			for _, p in pairs(char:GetDescendants()) do
				if p:IsA("BasePart") and p.Name ~= "HumanoidRootPart" and p.Transparency < 0.1 then
					p.Color = color
				end
			end
		end)
	end
	local function stopRGB() if rgbConnection then rgbConnection:Disconnect() rgbConnection = nil end end

	local function getClosestPlayer()
		local closest, shortest, myRoot = nil, math.huge, getRoot()
		if not myRoot then return end
		for _, plr in pairs(Players:GetPlayers()) do
			if plr ~= player and plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
				local d = (myRoot.Position - plr.Character.HumanoidRootPart.Position).Magnitude
				if d < shortest then shortest = d closest = plr end
			end
		end
		return closest
	end

	local function startGlue()
		if glueConnection then return end
		local t = getClosestPlayer()
		if not t then return end
		gluedTarget = t
		glueConnection = RunService.Heartbeat:Connect(function()
			if not glue or not gluedTarget then return end
			local myRoot = getRoot()
			local tr = gluedTarget.Character and gluedTarget.Character:FindFirstChild("HumanoidRootPart")
			if myRoot and tr then myRoot.CFrame = tr.CFrame * CFrame.new(0, 0, 1.5)
			else stopGlue() if glue then task.wait(0.2) startGlue() end end
		end)
	end
	local function stopGlue() if glueConnection then glueConnection:Disconnect() glueConnection = nil end gluedTarget = nil end


	local function startSpin()
		if spinConnection then return end
		spinConnection = RunService.Heartbeat:Connect(function()
			if not spinning then return end
			local r = getRoot()
			if r then r.CFrame = r.CFrame * CFrame.Angles(0, math.rad(spinSpeed), 0) end
		end)
	end
	local function stopSpin() if spinConnection then spinConnection:Disconnect() spinConnection = nil end end

	local function startSpin90()
		if spin90Connection then return end
		spin90Connection = RunService.Heartbeat:Connect(function()
			if not spinning90 then return end
			local r = getRoot()
			if r then
				r.CFrame = CFrame.new(r.Position) * CFrame.Angles(math.rad(90), math.rad(tick() * spinSpeed90), 0)
			end
		end)
	end
	local function stopSpin90() if spin90Connection then spin90Connection:Disconnect() spin90Connection = nil end end

	local function startMoveObjects()
		if moveConnection then return end
		moveConnection = Mouse.Button1Down:Connect(function()
			if not moveObjects then return end
			local t = Mouse.Target
			if t and t:IsA("BasePart") and not t:IsDescendantOf(player.Character) then
				selectedPart = t
				if selectedPart:FindFirstChild("YM_Select") then selectedPart.YM_Select:Destroy() end
				local s = Instance.new("SelectionBox")
				s.Name = "YM_Select"
				s.Adornee = selectedPart
				s.Color3 = Color3.fromRGB(255, 50, 50)
				s.Parent = selectedPart
			end
		end)
		RunService.Heartbeat:Connect(function()
			if moveObjects and selectedPart and selectedPart.Parent and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
				selectedPart.CFrame = CFrame.new(Mouse.Hit.Position)
			end
		end)
	end
	local function stopMoveObjects()
		if selectedPart and selectedPart:FindFirstChild("YM_Select") then selectedPart.YM_Select:Destroy() end
		selectedPart = nil
		if moveConnection then moveConnection:Disconnect() moveConnection = nil end
	end

	local function getPlayerUnderMouse()
		local target = Mouse.Target
		if not target then return nil end
		local character = target:FindFirstAncestorOfClass("Model")
		if not character then return nil end
		local plr = Players:GetPlayerFromCharacter(character)
		if not plr or plr == player or isTeammate(plr) then return nil end
		local hum = character:FindFirstChildOfClass("Humanoid")
		if not hum or hum.Health <= 0 then return nil end
		if visibilityCheckEnabled and not isVisibleFromCamera(target, character) then return nil end
		return plr
	end

	local function stopAutoClick()
		if autoClickHeld then
			pcall(function()
				VirtualUser:Button1Up(Vector2.new(Mouse.X, Mouse.Y), Camera.CFrame)
			end)
			autoClickHeld = false
		end
		if autoClickConnection then autoClickConnection:Disconnect() autoClickConnection = nil end
	end

	local function startAutoClick()
		if autoClickConnection then return end
		autoClickConnection = RunService.RenderStepped:Connect(function()
			if not autoClick then return end
			local targetPlayer = getPlayerUnderMouse()
			if targetPlayer then
				if not autoClickHeld then
					autoClickHeld = true
					pcall(function()
						VirtualUser:Button1Down(Vector2.new(Mouse.X, Mouse.Y), Camera.CFrame)
					end)
				end
			elseif autoClickHeld then
				pcall(function()
					VirtualUser:Button1Up(Vector2.new(Mouse.X, Mouse.Y), Camera.CFrame)
				end)
				autoClickHeld = false
			end
		end)
	end

	local function startClickTP()
		if clickTPConnection then return end
		clickTPConnection = Mouse.Button1Down:Connect(function()
			if not clickTP then return end
			local r = getRoot()
			if r then r.CFrame = CFrame.new(Mouse.Hit.Position + Vector3.new(0, 3, 0)) end
		end)
	end
	local function stopClickTP() if clickTPConnection then clickTPConnection:Disconnect() clickTPConnection = nil end end

	local function startKillAura()
		if killAuraConnection then return end
		killAuraConnection = RunService.Heartbeat:Connect(function()
			if not killAura then return end
			local myRoot = getRoot()
			if not myRoot then return end
			for _, plr in pairs(Players:GetPlayers()) do
				if plr ~= player and not isTeammate(plr) and plr.Character then
					local hum = plr.Character:FindFirstChildOfClass("Humanoid")
					local root = plr.Character:FindFirstChild("HumanoidRootPart")
					if hum and root and hum.Health > 0 and (myRoot.Position - root.Position).Magnitude < 15 then
						pcall(function() hum.Health = 0 end)
					end
				end
			end
		end)
	end
	local function stopKillAura() if killAuraConnection then killAuraConnection:Disconnect() killAuraConnection = nil end end


	local function startBringAll()
		if bringConnection then return end
		bringConnection = RunService.Heartbeat:Connect(function()
			if not bringAll then return end
			local myRoot = getRoot()
			if not myRoot then return end
			for _, plr in pairs(Players:GetPlayers()) do
				if plr ~= player and plr.Character then
					local root = plr.Character:FindFirstChild("HumanoidRootPart")
					if root then root.CFrame = myRoot.CFrame * CFrame.new(0, 0, 5) end
				end
			end
		end)
	end
	local function stopBringAll() if bringConnection then bringConnection:Disconnect() bringConnection = nil end end

	local function startInfiniteJump()
		if jumpConnection then return end
		jumpConnection = UserInputService.JumpRequest:Connect(function()
			if not infiniteJump then return end
			local h = getHumanoid()
			if h then h:ChangeState(Enum.HumanoidStateType.Jumping) end
		end)
	end
	local function stopInfiniteJump() if jumpConnection then jumpConnection:Disconnect() jumpConnection = nil end end

	local function startNoFallDamage()
		if fallConnection then return end
		fallConnection = RunService.Heartbeat:Connect(function()
			if not noFallDamage then return end
			local h = getHumanoid()
			if h and h:GetState() == Enum.HumanoidStateType.Freefall then
				h:ChangeState(Enum.HumanoidStateType.GettingUp)
			end
		end)
	end
	local function stopNoFallDamage() if fallConnection then fallConnection:Disconnect() fallConnection = nil end end

	local function startAntiAFK()
		if antiAFKConnection then return end
		antiAFKConnection = player.Idled:Connect(function()
			VirtualUser:CaptureController()
			VirtualUser:ClickButton2(Vector2.new())
		end)
	end
	local function stopAntiAFK() if antiAFKConnection then antiAFKConnection:Disconnect() antiAFKConnection = nil end end

	local function startRagdoll()
		local char = getChar()
		local hum = getHumanoid()
		if not char or not hum then return end
		hum.PlatformStand = true
		hum:ChangeState(Enum.HumanoidStateType.Physics)
		for _, v in pairs(char:GetDescendants()) do
			if v:IsA("Motor6D") and v.Part0 and v.Part1 then
				local att0 = Instance.new("Attachment")
				att0.Name = "YM_RagA0"
				att0.CFrame = v.C0
				att0.Parent = v.Part0
				local att1 = Instance.new("Attachment")
				att1.Name = "YM_RagA1"
				att1.CFrame = v.C1
				att1.Parent = v.Part1
				local ball = Instance.new("BallSocketConstraint")
				ball.Name = "YM_Ragdoll"
				ball.Attachment0 = att0
				ball.Attachment1 = att1
				ball.LimitsEnabled = false
				ball.Parent = v.Part0
				table.insert(ragdollConstraints, {motor = v, ball = ball, att0 = att0, att1 = att1})
				v.Enabled = false
			end
		end
	end
	local function stopRagdoll()
		local hum = getHumanoid()
		if hum then
			hum.PlatformStand = false
			hum:ChangeState(Enum.HumanoidStateType.GettingUp)
		end
		for _, data in pairs(ragdollConstraints) do
			if data.motor then data.motor.Enabled = true end
			if data.ball then data.ball:Destroy() end
			if data.att0 then data.att0:Destroy() end
			if data.att1 then data.att1:Destroy() end
		end
		table.clear(ragdollConstraints)
	end

	-- ========== FORCE x1000 CORRIGÉE ==========
	local function setupSuperForce(char)
		for _, conn in pairs(forceConnections) do
			conn:Disconnect()
		end
		table.clear(forceConnections)
		if not superForce or not char then return end
		for _, part in pairs(char:GetDescendants()) do
			if part:IsA("BasePart") then
				local conn = part.Touched:Connect(function(hit)
					if not superForce then return end
					local enemyChar = hit:FindFirstAncestorOfClass("Model")
					if not enemyChar or enemyChar == char then return end
					local enemyHum = enemyChar:FindFirstChildOfClass("Humanoid")
					local enemyRoot = enemyChar:FindFirstChild("HumanoidRootPart")
					local myRoot = getRoot()
					if enemyHum and enemyRoot and myRoot and enemyHum.Health > 0 then
						local direction = (enemyRoot.Position - myRoot.Position)
						if direction.Magnitude < 0.8 then
							direction = myRoot.CFrame.LookVector
						else
							direction = direction.Unit
						end
						local power = forcePower
						enemyRoot.AssemblyLinearVelocity = direction * power + Vector3.new(0, power * 0.55, 0)
						local bv = Instance.new("BodyVelocity")
						bv.Velocity = direction * power + Vector3.new(0, power * 0.5, 0)
						bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
						bv.Parent = enemyRoot
						game:GetService("Debris"):AddItem(bv, 0.45)
					end
				end)
				table.insert(forceConnections, conn)
			end
		end
	end

	-- ESP Squelette
	local function clearSkeleton()
		for _, drawings in pairs(skeletonDrawings) do
			for _, d in pairs(drawings) do if d and d.Remove then d:Remove() end end
		end
		table.clear(skeletonDrawings)
	end
	local function startSkeletonESP()
		if skeletonConnection then return end
		skeletonConnection = RunService.RenderStepped:Connect(function()
			if not skeletonESP then return end
			clearSkeleton()
			for _, plr in pairs(Players:GetPlayers()) do
				if plr ~= player and not isTeammate(plr) and plr.Character then
					local char = plr.Character
					local bones = {
						{"Head","UpperTorso"},{"UpperTorso","LowerTorso"},
						{"UpperTorso","LeftUpperArm"},{"LeftUpperArm","LeftLowerArm"},{"LeftLowerArm","LeftHand"},
						{"UpperTorso","RightUpperArm"},{"RightUpperArm","RightLowerArm"},{"RightLowerArm","RightHand"},
						{"LowerTorso","LeftUpperLeg"},{"LeftUpperLeg","LeftLowerLeg"},{"LeftLowerLeg","LeftFoot"},
						{"LowerTorso","RightUpperLeg"},{"RightUpperLeg","RightLowerLeg"},{"RightLowerLeg","RightFoot"}
					}
					if not char:FindFirstChild("UpperTorso") then
						bones = {{"Head","Torso"},{"Torso","Left Arm"},{"Torso","Right Arm"},{"Torso","Left Leg"},{"Torso","Right Leg"}}
					end
					local drawings = {}
					for _, pair in pairs(bones) do
						local p1 = char:FindFirstChild(pair[1])
						local p2 = char:FindFirstChild(pair[2])
						if p1 and p2 then
							local pos1, on1 = Camera:WorldToViewportPoint(p1.Position)
							local pos2, on2 = Camera:WorldToViewportPoint(p2.Position)
							if on1 or on2 then
								local line = Drawing.new("Line")
								line.From = Vector2.new(pos1.X, pos1.Y)
								line.To = Vector2.new(pos2.X, pos2.Y)
								line.Color = Color3.fromRGB(255, 50, 50)
								line.Thickness = 1.5
								line.Visible = true
								table.insert(drawings, line)
							end
						end
					end
					skeletonDrawings[plr] = drawings
				end
			end
		end)
	end
	local function stopSkeletonESP()
		if skeletonConnection then skeletonConnection:Disconnect() skeletonConnection = nil end
		clearSkeleton()
	end

	local function clearNameHealth()
		for _, bb in pairs(nameHealthBillboards) do if bb then bb:Destroy() end end
		table.clear(nameHealthBillboards)
	end

	local function startNameGlitch()
		if nameGlitchConnection then return end
		local char = getChar()
		if not char then return end
		local head = char:FindFirstChild("Head")
		if not head then return end
		if nameGlitchBillboard then nameGlitchBillboard:Destroy() end
		local bb = Instance.new("BillboardGui")
		bb.Name = "YM_NameGlitch"
		bb.Adornee = head
		bb.Size = UDim2.new(0, 260, 0, 40)
		bb.StudsOffset = Vector3.new(0, 3.3, 0)
		bb.AlwaysOnTop = true
		bb.Parent = head
		local label = Instance.new("TextLabel")
		label.Size = UDim2.new(1, 0, 1, 0)
		label.BackgroundTransparency = 1
		label.Font = Enum.Font.GothamBlack
		label.TextSize = 18
		label.TextStrokeTransparency = 0.3
		label.Parent = bb
		nameGlitchBillboard = bb
		local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%&*!?"
		nameGlitchConnection = RunService.Heartbeat:Connect(function()
			if not nameGlitch or not label or not label.Parent then return end
			local glitchText = ""
			for i = 1, 14 do
				glitchText = glitchText .. string.sub(chars, math.random(1, #chars), math.random(1, #chars))
			end
			label.Text = glitchText
			label.TextColor3 = Color3.fromHSV((tick() * 3) % 1, 1, 1)
		end)
	end
	local function stopNameGlitch()
		if nameGlitchConnection then nameGlitchConnection:Disconnect() nameGlitchConnection = nil end
		if nameGlitchBillboard then nameGlitchBillboard:Destroy() nameGlitchBillboard = nil end
	end

	local function startFakeLagTP()
		if fakeLagTPConnection then return end
		fakeLagTPConnection = RunService.Heartbeat:Connect(function()
			if not fakeLagTP then return end
			local root = getRoot()
			if root and math.random(1, 8) == 1 then
				local offset = Vector3.new(math.random(-4, 4), 0, math.random(-4, 4))
				root.CFrame = root.CFrame + offset
				task.wait(0.05)
				root.CFrame = root.CFrame - offset
			end
		end)
	end
	local function stopFakeLagTP() if fakeLagTPConnection then fakeLagTPConnection:Disconnect() fakeLagTPConnection = nil end end

	local function startFakeLagAngles()
		if fakeLagAnglesConnection then return end
		fakeLagAnglesConnection = RunService.Heartbeat:Connect(function()
			if not fakeLagAngles then return end
			local root = getRoot()
			if root then
				root.CFrame = CFrame.new(root.Position) * CFrame.Angles(
					math.rad(math.random(-60, 60)),
					math.rad(math.random(0, 360)),
					math.rad(math.random(-40, 40))
				)
			end
		end)
	end
	local function stopFakeLagAngles() if fakeLagAnglesConnection then fakeLagAnglesConnection:Disconnect() fakeLagAnglesConnection = nil end end

	-- ========== ESP BOX RGB + LIGNE CENTRALE + VIE + NOM + DISTANCE ==========
	local function removeBoxESP(plr)
		local data = boxESPObjects[plr]
		if data then
			for _, obj in pairs(data) do if obj and obj.Remove then pcall(function() obj:Remove() end) end end
			boxESPObjects[plr] = nil
		end
	end
	local function clearBoxESP() for plr in pairs(boxESPObjects) do removeBoxESP(plr) end end
	local function startBoxESP()
		if boxESPConnection then return end
		boxESPConnection = RunService.RenderStepped:Connect(function()
			if not boxESP then return end
			local rgbColor = Color3.fromHSV((tick() * 0.25) % 1, 1, 1)
			local currentCamera = workspace.CurrentCamera or Camera
			if not currentCamera then return end
			Camera = currentCamera
			local viewport = currentCamera.ViewportSize
			local screenCenter = Vector2.new(viewport.X / 2, viewport.Y / 2)
			for _, plr in pairs(Players:GetPlayers()) do
				if plr ~= player and not isTeammate(plr) and plr.Character then
					local char = plr.Character
					local root, head = char:FindFirstChild("HumanoidRootPart"), char:FindFirstChild("Head")
					local hum = char:FindFirstChildOfClass("Humanoid")
					if root and head and hum and hum.Health > 0 then
						local top3, topOn = currentCamera:WorldToViewportPoint(head.Position + Vector3.new(0, 0.35, 0))
						local bot3, botOn = currentCamera:WorldToViewportPoint(root.Position - Vector3.new(0, 3, 0))
						if (topOn or botOn) and top3.Z > 0 and bot3.Z > 0 then
							local h = math.max(12, math.abs(bot3.Y - top3.Y)); local w = math.max(8, h * 0.55)
							local x, y = top3.X - w/2, top3.Y
							local d = boxESPObjects[plr]
							if not d then
								d = {box=Drawing.new("Square"), line=Drawing.new("Line"), healthBG=Drawing.new("Square"), health=Drawing.new("Square"), name=Drawing.new("Text"), distance=Drawing.new("Text")}
								d.box.Filled=false; d.box.Thickness=2; d.line.Thickness=1.5; d.healthBG.Filled=true; d.health.Filled=true
								d.name.Center=true; d.name.Outline=true; d.name.Size=13; d.name.Font=2
								d.distance.Center=true; d.distance.Outline=true; d.distance.Size=11; d.distance.Font=2
								boxESPObjects[plr]=d
							end
							d.box.Position=Vector2.new(x,y); d.box.Size=Vector2.new(w,h)
							d.box.Color = rgbColor
							d.box.Visible=true
							d.line.From=screenCenter; d.line.To=Vector2.new(x+w/2,y+h/2)
							d.line.Color = rgbColor
							d.line.Visible = boxESP
							d.healthBG.Visible=true
							d.health.Visible=true
							d.name.Visible=true
							d.distance.Visible=true
							local ratio=math.clamp(hum.Health/math.max(hum.MaxHealth,1),0,1); local bx=x+w+4
							d.healthBG.Position=Vector2.new(bx,y); d.healthBG.Size=Vector2.new(4,h); d.healthBG.Color=Color3.fromRGB(25,25,25); d.healthBG.Visible=true
							d.health.Position=Vector2.new(bx,y+h*(1-ratio)); d.health.Size=Vector2.new(4,h*ratio); d.health.Color=Color3.fromHSV(math.clamp(ratio*.33,0,.33),1,1); d.health.Visible=true
							d.name.Position=Vector2.new(top3.X, y-16); d.name.Text=plr.DisplayName; d.name.Color=rgbColor; d.name.Visible=true
							local myRoot=getRoot(); local dist=myRoot and (myRoot.Position-root.Position).Magnitude or 0
							d.distance.Position=Vector2.new(top3.X, y+h+3); d.distance.Text=string.format("%dm", math.floor(dist+0.5)); d.distance.Color=rgbColor; d.distance.Visible=true
						else removeBoxESP(plr) end
					else removeBoxESP(plr) end
				end
			end
		end)
	end
	local function stopBoxESP() if boxESPConnection then boxESPConnection:Disconnect(); boxESPConnection=nil end; clearBoxESP() end

	local function createESP(plr)
		if plr == player or highlights[plr] or isTeammate(plr) then return end
		local char = plr.Character
		if not char then return end
		local h = Instance.new("Highlight")
		h.FillColor = Color3.fromRGB(180, 0, 0)
		h.OutlineColor = Color3.fromRGB(255, 40, 40)
		h.FillTransparency = 0.45
		h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
		h.Parent = char
		highlights[plr] = h
	end
	local function removeESP(plr)
		if highlights[plr] then highlights[plr]:Destroy() highlights[plr] = nil end
	end
	local function updateESP()
		for _, plr in pairs(Players:GetPlayers()) do
			if esp and plr.Character and not isTeammate(plr) then
				createESP(plr)
			else
				removeESP(plr)
			end
		end
	end

	local function getClosestHead()
		local closest, shortest = nil, math.huge
		local currentCamera = workspace.CurrentCamera
		if not currentCamera then return end
		local screenCenter = currentCamera.ViewportSize * 0.5
		for _, plr in pairs(Players:GetPlayers()) do
			if plr ~= player and plr.Character then
				local head = plr.Character:FindFirstChild("Head")
				local hum = plr.Character:FindFirstChildOfClass("Humanoid")
				if head and hum and hum.Health > 0 then
					local pos, onScreen = currentCamera:WorldToViewportPoint(head.Position)
					if onScreen and pos.Z > 0 then
						local d = (Vector2.new(pos.X, pos.Y) - screenCenter).Magnitude
						if d < shortest then shortest = d closest = head end
					end
				end
			end
		end
		return closest
	end

	local function teleportToPlayer(target)
		if not target or target == player then return end
		local myRoot = getRoot()
		local tr = target.Character and target.Character:FindFirstChild("HumanoidRootPart")
		if myRoot and tr then myRoot.CFrame = tr.CFrame * CFrame.new(0, 0, 3.5) end
	end

	local function spectatePlayer(target)
		if not target or not target.Character then return end
		local hum = target.Character:FindFirstChildOfClass("Humanoid")
		if hum then Camera.CameraSubject = hum end
	end
	local function stopSpectate()
		local hum = getHumanoid()
		if hum then Camera.CameraSubject = hum end
	end

	-------------------------------------------------
	-- INTERFACE - CARTOGRAPHIE 0.6 / OUTILS 0.5
	-------------------------------------------------
	local ScreenGui = Instance.new("ScreenGui")
	ScreenGui.Name = "Core" .. math.random(100000, 999999)
	ScreenGui.ResetOnSpawn = false
	ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
	ScreenGui.Parent = player:WaitForChild("PlayerGui")

	local WINDOW_BACKGROUND_IMAGE = "rbxassetid://100446752830441"
	local BUTTON_BACKGROUND_IMAGE = "rbxassetid://115507210213862"

	local Main = Instance.new("Frame")
	Main.Name = "Main"
	Main.Size = UDim2.new(0, 720, 0, 520)
	Main.Position = UDim2.new(0.5, -360, 0.5, -260)
	Main.BackgroundColor3 = Color3.fromRGB(15, 5, 5)
	Main.BackgroundTransparency = 0.15
	Main.BorderSizePixel = 0
	Main.Active = true
	Main.Parent = ScreenGui
	local INITIAL_MAIN_POSITION = Main.Position
	Instance.new("UICorner", Main).CornerRadius = UDim.new(0, 10)

	local Background = Instance.new("ImageLabel")
	Background.Name = "YM_WindowBackground"
	Background.Size = UDim2.fromScale(1, 1)
	Background.BackgroundTransparency = 1
	Background.Image = WINDOW_BACKGROUND_IMAGE
	Background.ImageTransparency = 0.08
	Background.ScaleType = Enum.ScaleType.Crop
	Background.BorderSizePixel = 0
	Background.ZIndex = 1
	Background.Parent = Main
	Instance.new("UICorner", Background).CornerRadius = UDim.new(0, 10)

	local Title = Instance.new("TextLabel")
	Title.Size = UDim2.new(1, -30, 0, 42)
	Title.Position = UDim2.new(0, 15, 0, 8)
	Title.BackgroundTransparency = 1
	Title.Text = "YM TOOL"
	Title.TextColor3 = Color3.fromRGB(255, 255, 255)
	Title.TextStrokeTransparency = 0.15
	Title.Font = Enum.Font.GothamBold
	Title.TextSize = 24
	Title.TextXAlignment = Enum.TextXAlignment.Left
	Title.ZIndex = 20
	Title.Parent = Main

	local SearchBox = Instance.new("TextBox")
	SearchBox.Size = UDim2.new(1, -30, 0, 34)
	SearchBox.Position = UDim2.new(0, 15, 0, 54)
	SearchBox.BackgroundColor3 = Color3.fromRGB(20, 5, 5)
	SearchBox.BackgroundTransparency = 0.2
	SearchBox.Text = ""
	SearchBox.PlaceholderText = "🔎 Rechercher un onglet / une option..."
	SearchBox.PlaceholderColor3 = Color3.fromRGB(190, 170, 170)
	SearchBox.TextColor3 = Color3.fromRGB(255, 255, 255)
	SearchBox.Font = Enum.Font.Gotham
	SearchBox.TextSize = 13
	SearchBox.ClearTextOnFocus = false
	SearchBox.ZIndex = 20
	SearchBox.Parent = Main
	Instance.new("UICorner", SearchBox).CornerRadius = UDim.new(0, 6)

	local Sidebar = Instance.new("Frame")
	Sidebar.Size = UDim2.new(0, 185, 1, -110)
	Sidebar.Position = UDim2.new(0, 15, 0, 100)
	Sidebar.BackgroundColor3 = Color3.fromRGB(10, 3, 3)
	Sidebar.BackgroundTransparency = 0.2
	Sidebar.BorderSizePixel = 0
	Sidebar.ZIndex = 10
	Sidebar.Parent = Main
	Instance.new("UICorner", Sidebar).CornerRadius = UDim.new(0, 8)

	-- Zone scrollable uniquement pour les boutons de catégories.
	-- La fenêtre principale et la Sidebar gardent exactement leur taille.
	local CategoryScroll = Instance.new("ScrollingFrame")
	CategoryScroll.Name = "CategoryScroll"
	CategoryScroll.Size = UDim2.new(1, -16, 1, -20)
	CategoryScroll.Position = UDim2.new(0, 8, 0, 10)
	CategoryScroll.BackgroundTransparency = 1
	CategoryScroll.BorderSizePixel = 0
	CategoryScroll.ScrollBarThickness = 5
	CategoryScroll.ScrollBarImageColor3 = Color3.fromRGB(180, 0, 0)
	CategoryScroll.ScrollingDirection = Enum.ScrollingDirection.Y
	CategoryScroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
	CategoryScroll.CanvasSize = UDim2.new(0, 0, 0, 0)
	CategoryScroll.Active = true
	CategoryScroll.ZIndex = 20
	CategoryScroll.Parent = Sidebar

	local SidebarLayout = Instance.new("UIListLayout")
	SidebarLayout.Padding = UDim.new(0, 7)
	SidebarLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
	SidebarLayout.SortOrder = Enum.SortOrder.LayoutOrder
	SidebarLayout.Parent = CategoryScroll
	local SidebarPadding = Instance.new("UIPadding")
	SidebarPadding.PaddingTop = UDim.new(0, 0)
	SidebarPadding.PaddingLeft = UDim.new(0, 0)
	SidebarPadding.PaddingRight = UDim.new(0, 0)
	SidebarPadding.PaddingBottom = UDim.new(0, 10)
	SidebarPadding.Parent = CategoryScroll

	local Content = Instance.new("Frame")
	Content.Size = UDim2.new(1, -220, 1, -110)
	Content.Position = UDim2.new(0, 205, 0, 100)
	Content.BackgroundColor3 = Color3.fromRGB(10, 3, 3)
	Content.BackgroundTransparency = 0.25
	Content.BorderSizePixel = 0
	Content.ZIndex = 10
	Content.Parent = Main
	Instance.new("UICorner", Content).CornerRadius = UDim.new(0, 8)

	local ContentTitle = Instance.new("TextLabel")
	ContentTitle.Size = UDim2.new(1, -24, 0, 40)
	ContentTitle.Position = UDim2.new(0, 12, 0, 10)
	ContentTitle.BackgroundTransparency = 1
	ContentTitle.Text = "ACCUEIL"
	ContentTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
	ContentTitle.TextStrokeTransparency = 0.2
	ContentTitle.Font = Enum.Font.GothamBold
	ContentTitle.TextSize = 20
	ContentTitle.TextXAlignment = Enum.TextXAlignment.Left
	ContentTitle.ZIndex = 30
	ContentTitle.Parent = Content

	local Description = Instance.new("TextLabel")
	Description.Size = UDim2.new(1, -24, 0, 82)
	Description.Position = UDim2.new(0, 12, 0, 55)
	Description.BackgroundTransparency = 1
	Description.Text = "Bonjour, nous sommes YM TOOL ! Un tool universel pour chaque jeu et utilisation.\nNous ne sommes pas responsable de vos bannissement et nous respectons les mentions de ScriptBlox."
	Description.TextColor3 = Color3.fromRGB(235, 220, 220)
	Description.Font = Enum.Font.Gotham
	Description.TextSize = 14
	Description.TextWrapped = true
	Description.TextXAlignment = Enum.TextXAlignment.Left
	Description.TextYAlignment = Enum.TextYAlignment.Top
	Description.ZIndex = 30
	Description.Parent = Content

	local ScriptBloxCounter = Instance.new("TextLabel")
	ScriptBloxCounter.Size = UDim2.new(1, -24, 0, 26)
	ScriptBloxCounter.Position = UDim2.new(0, 12, 0, 145)
	ScriptBloxCounter.BackgroundTransparency = 1
	ScriptBloxCounter.Text = "ScriptBlox • chargement..."
	ScriptBloxCounter.TextColor3 = Color3.fromRGB(180, 180, 180)
	ScriptBloxCounter.Font = Enum.Font.GothamBold
	ScriptBloxCounter.TextSize = 12
	ScriptBloxCounter.TextXAlignment = Enum.TextXAlignment.Left
	ScriptBloxCounter.ZIndex = 30
	ScriptBloxCounter.Parent = Content

	local DiscHome = Instance.new("TextButton")
	DiscHome.Size = UDim2.new(1, -24, 0, 34)
	DiscHome.Position = UDim2.new(0, 12, 0, 185)
	DiscHome.BackgroundColor3 = Color3.fromRGB(60, 20, 100)
	DiscHome.Text = "Discord : discord.gg/cKPHdt99WG"
	DiscHome.TextColor3 = Color3.fromRGB(220, 200, 255)
	DiscHome.Font = Enum.Font.GothamBold
	DiscHome.TextSize = 13
	DiscHome.ZIndex = 30
	DiscHome.Parent = Content
	Instance.new("UICorner", DiscHome).CornerRadius = UDim.new(0, 6)
	DiscHome.MouseButton1Click:Connect(function()
		if setclipboard then
			setclipboard("https://discord.gg/cKPHdt99WG")
			DiscHome.Text = "✅ Lien copié !"
			task.wait(1.5)
			DiscHome.Text = "Discord : discord.gg/cKPHdt99WG"
		end
	end)

	local HttpService = game:GetService("HttpService")
	local function refreshScriptBloxCounter()
		local ok, result = pcall(function()
			return game:HttpGet("https://scriptblox.com/api/script/search?q=YM%20TOOL&max=20")
		end)
		if not ok then ScriptBloxCounter.Text = "ScriptBlox • indisponible" return end
		local decodedOk, data = pcall(function() return HttpService:JSONDecode(result) end)
		if not decodedOk or not data or not data.result or not data.result.scripts then
			ScriptBloxCounter.Text = "ScriptBlox • données indisponibles"
			return
		end
		for _, scriptData in ipairs(data.result.scripts) do
			if string.lower(scriptData.title or "") == "ym tool" then
				local views = tonumber(scriptData.views) or 0
				ScriptBloxCounter.Text = string.format("Powered by ScriptBlox.com • %s vues", tostring(views):reverse():gsub("(%d%d%d)", "%1 "):reverse():gsub("^ ", ""))
				return
			end
		end
		ScriptBloxCounter.Text = "Powered by ScriptBlox.com • YM TOOL introuvable"
	end
	task.spawn(function()
		while ScreenGui.Parent do
			refreshScriptBloxCounter()
			task.wait(60)
		end
	end)

	local PageHolder = Instance.new("Frame")
	PageHolder.Size = UDim2.new(1, -16, 1, -62)
	PageHolder.Position = UDim2.new(0, 8, 0, 52)
	PageHolder.BackgroundTransparency = 1
	PageHolder.ZIndex = 20
	PageHolder.Parent = Content

	local categories = {"ACCUEIL", "VALEURS MODIFIABLE", "FUN", "PVP", "RAGEBAIT", "ONLY YOUR EYES", "BOUTONS", "PRESET", "THEME EDITOR"}
	local pages = {}
	local categoryButtons = {}
	local activePage = nil
	local searchTargets = {}

	local function makePage(name)
		local page = Instance.new("ScrollingFrame")
		page.Name = "Page_" .. name:gsub("%W", "_")
		page.Size = UDim2.fromScale(1, 1)
		page.BackgroundTransparency = 1
		page.BorderSizePixel = 0
		page.ScrollBarThickness = 5
		page.ScrollBarImageColor3 = Color3.fromRGB(180, 0, 0)
		page.AutomaticCanvasSize = Enum.AutomaticSize.Y
		page.Visible = false
		page.ZIndex = 25
		page.Parent = PageHolder
		local pad = Instance.new("UIPadding")
		pad.PaddingTop = UDim.new(0, 4)
		pad.PaddingBottom = UDim.new(0, 10)
		pad.PaddingLeft = UDim.new(0, 4)
		pad.PaddingRight = UDim.new(0, 4)
		pad.Parent = page
		local list = Instance.new("UIListLayout")
		list.Padding = UDim.new(0, 5)
		list.SortOrder = Enum.SortOrder.LayoutOrder
		list.Parent = page
		pages[name] = page
		return page
	end

	for _, name in ipairs(categories) do makePage(name) end

	local function showCategory(name)
		for n, page in pairs(pages) do page.Visible = (n == name) end
		for n, btn in pairs(categoryButtons) do
			btn.BackgroundTransparency = (n == name) and 0.02 or 0.15
		end
		ContentTitle.Text = name
		Description.Visible = (name == "ACCUEIL")
		ScriptBloxCounter.Visible = (name == "ACCUEIL")
		DiscHome.Visible = (name == "ACCUEIL")
	end

	for _, name in ipairs(categories) do
		local Button = Instance.new("TextButton")
		Button.Size = UDim2.new(1, -16, 0, 42)
		Button.BackgroundColor3 = Color3.fromRGB(25, 7, 7)
		Button.BackgroundTransparency = 0.15
		Button.Text = name
		Button.TextColor3 = Color3.fromRGB(245, 225, 225)
		Button.TextStrokeTransparency = 0.15
		Button.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		Button.Font = Enum.Font.GothamBold
		Button.TextSize = 12
		Button.AutoButtonColor = true
		Button.ZIndex = 30
		Button.Parent = CategoryScroll
		Instance.new("UICorner", Button).CornerRadius = UDim.new(0, 6)
		categoryButtons[name] = Button
		Button.MouseButton1Click:Connect(function() showCategory(name) end)
	end

	-- THEME EDITOR
	-- Construit seulement après la création des pages et boutons.
	local ThemeState = {animations = true}
	local themeOk, themeResult = pcall(buildThemeEditor, {
		ScreenGui = ScreenGui, Main = Main, Content = Content, Sidebar = Sidebar, Background = Background,
		categoryButtons = categoryButtons, pages = pages, player = player, RunService = RunService, HttpService = HttpService,
		SearchBox = SearchBox, ContentTitle = ContentTitle, Title = Title, WindowHeader = Title, InitialMainPosition = INITIAL_MAIN_POSITION,
		WINDOW_BACKGROUND_IMAGE = WINDOW_BACKGROUND_IMAGE, BUTTON_BACKGROUND_IMAGE = BUTTON_BACKGROUND_IMAGE,
	})
	if themeOk and type(themeResult) == "table" then
		ThemeState = themeResult
	else
		warn("YM TOOL | Theme Editor désactivé : " .. tostring(themeResult))
	end

	local dragging = false
	local dragStart
	local startPosition
	Title.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			dragStart = input.Position
			startPosition = Main.Position
			input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then dragging = false end
			end)
		end
	end)
	UserInputService.InputChanged:Connect(function(input)
		if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
			local delta = input.Position - dragStart
			Main.Position = UDim2.new(startPosition.X.Scale, startPosition.X.Offset + delta.X, startPosition.Y.Scale, startPosition.Y.Offset + delta.Y)
		end
	end)

	-- Fenêtre DEBUG séparée (créée après ScreenGui/Main pour garantir son affichage)
	local DebugFrame = Instance.new("Frame")
	DebugFrame.Name = "YM_DEBUG"
	DebugFrame.Size = UDim2.fromOffset(300, 360)
	DebugFrame.AnchorPoint = Vector2.new(0, 0.5)
	DebugFrame.Position = UDim2.new(0.5, 165, 0.5, 0)
	DebugFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
	DebugFrame.Visible = false
	DebugFrame.Active = true
	DebugFrame.Draggable = true
	DebugFrame.Parent = ScreenGui
	Instance.new("UICorner", DebugFrame).CornerRadius = UDim.new(0, 10)
	local debugStroke = Instance.new("UIStroke")
	debugStroke.Color = Color3.fromRGB(160, 0, 0)
	debugStroke.Parent = DebugFrame

	local DebugTitle = Instance.new("TextLabel")
	DebugTitle.Size = UDim2.new(1, -40, 0, 40)
	DebugTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	DebugTitle.Text = "YM TOOL  |  DEBUG"
	DebugTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
	DebugTitle.Font = Enum.Font.GothamBlack
	DebugTitle.TextSize = 16
	DebugTitle.Parent = DebugFrame
	Instance.new("UICorner", DebugTitle).CornerRadius = UDim.new(0, 10)

	local DebugClose = Instance.new("TextButton")
	DebugClose.Size = UDim2.fromOffset(40, 40)
	DebugClose.Position = UDim2.new(1, -38, 0, 0)
	DebugClose.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	DebugClose.Text = "X"
	DebugClose.TextColor3 = Color3.fromRGB(255,255,255)
	DebugClose.Font = Enum.Font.GothamBlack
	DebugClose.TextSize = 17
	DebugClose.Parent = DebugFrame
	Instance.new("UICorner", DebugClose).CornerRadius = UDim.new(0, 10)
	DebugClose.MouseButton1Click:Connect(function()
		DebugFrame.Visible = false
		debugVisible = false
	end)
	DebugFrame.Visible = false
	DebugFrame.ZIndex = 100

	local DebugStatus = Instance.new("TextLabel")
	DebugStatus.Size = UDim2.new(1, -20, 0, 22)
	DebugStatus.Position = UDim2.fromOffset(10, 42)
	DebugStatus.BackgroundTransparency = 1
	DebugStatus.Text = "● LIVE DEBUG"
	DebugStatus.TextColor3 = Color3.fromRGB(0, 255, 100)
	DebugStatus.Font = Enum.Font.GothamBold
	DebugStatus.TextSize = 12
	DebugStatus.TextXAlignment = Enum.TextXAlignment.Left
	DebugStatus.Parent = DebugFrame

	local DebugLabel = Instance.new("TextLabel")
	DebugLabel.Size = UDim2.new(1, -20, 1, -60)
	DebugLabel.Position = UDim2.fromOffset(10, 54)
	DebugLabel.BackgroundTransparency = 1
	DebugLabel.TextColor3 = Color3.fromRGB(220,220,220)
	DebugLabel.Font = Enum.Font.Code
	DebugLabel.TextSize = 13
	DebugLabel.TextXAlignment = Enum.TextXAlignment.Left
	DebugLabel.TextYAlignment = Enum.TextYAlignment.Top
	DebugLabel.TextWrapped = false
	DebugLabel.Text = "FPS          : ...\nPing         : ...\nPosition     : ...\nVelocity     : ...\nHumanoid     : ...\nCamera FOV   : ...\nServer       : ...\nClient       : LocalScript"
	DebugLabel.Parent = DebugFrame

	-- Tous les éléments DEBUG restent au-dessus de la fenêtre
	DebugTitle.ZIndex = 101
	DebugClose.ZIndex = 102
	DebugStatus.ZIndex = 101
	DebugLabel.ZIndex = 101

	task.spawn(function()
		local last = tick()
		local frames = 0
		local shownFPS = 0
		while DebugFrame.Parent do
			RunService.RenderStepped:Wait()
			frames += 1
			local now = tick()
			if now - last >= 0.5 then
				shownFPS = math.floor(frames / (now-last) + 0.5)
				frames = 0
				last = now
			end
			if debugVisible then
				local currentCamera = workspace.CurrentCamera
				local root = getRoot()
				local hum = getHumanoid()
				local pos = root and root.Position or Vector3.zero
				local vel = root and root.AssemblyLinearVelocity or Vector3.zero
				local state = hum and hum:GetState().Name or "N/A"
				local ping = "N/A"
				pcall(function()
					local stats = game:GetService("Stats")
					local network = stats:FindFirstChild("Network")
					local serverStats = network and network:FindFirstChild("ServerStatsItem")
					local item = serverStats and serverStats:FindFirstChild("Data Ping")
					if item then ping = tostring(math.floor(item:GetValue())) .. " ms" end
				end)
				DebugLabel.Text = string.format(
					"FPS          : %d\nPing         : %s\nPosition     : %.1f, %.1f, %.1f\nVelocity     : %.1f, %.1f, %.1f\nHumanoid     : %s\nCamera FOV   : %.1f\nServer       : %s\nClient       : %s",
					shownFPS, ping,
					pos.X, pos.Y, pos.Z,
					vel.X, vel.Y, vel.Z,
					state,
					currentCamera and currentCamera.FieldOfView or 0,
					game.JobId ~= "" and game.JobId or "N/A",
					"LocalScript"
				)
			end
		end
	end)


		local function buildDirectButtonUI()
local Title = Instance.new("TextLabel")
	Title.Size = UDim2.new(1, 0, 0, 48)
	Title.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	Title.Text = "YM TOOL  |  P pour cacher"
	Title.TextColor3 = Color3.fromRGB(220, 20, 20)
	Title.Font = Enum.Font.GothamBlack
	Title.TextSize = 20
	Title.Parent = Main
	Instance.new("UICorner", Title).CornerRadius = UDim.new(0, 10)

	-- Recherche rapide + compteur ScriptBlox
		local function setActivePage(name)
		activePage = pages[name]
		return activePage
	end

	setActivePage("FUN")
	local toggleRegistry = {}
	local function createToggle(text, callback)
		local btn = Instance.new("TextButton")
		btn.Size = UDim2.new(1, -10, 0, 34)
		btn.BackgroundColor3 = Color3.fromRGB(20, 5, 5)
		btn.Text = text .. " | OFF"
		btn.TextColor3 = Color3.fromRGB(255, 55, 55)
		btn.Font = Enum.Font.GothamBold
		btn.TextSize = 13
		btn.TextTransparency = 0
		btn.TextStrokeTransparency = 0
		btn.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		btn.TextXAlignment = Enum.TextXAlignment.Center
		btn.TextYAlignment = Enum.TextYAlignment.Center
		btn.BackgroundTransparency = 0.58
		btn.BorderSizePixel = 0
		btn.AutoButtonColor = false
		btn.ZIndex = 20
		btn.Parent = activePage
		table.insert(searchTargets, {button = btn, text = text})
		Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6)
		local stroke = Instance.new("UIStroke")
		stroke.Color = Color3.fromRGB(90, 0, 0)
		stroke.Parent = btn
		local on = false
		local function setState(state)
			state = state == true
			if on == state then return end
			on = state
			if on then
				btn.Text = text .. " | ON"
				btn.TextColor3 = Color3.fromRGB(90, 255, 120)
				btn.BackgroundColor3 = Color3.fromRGB(10, 35, 15)
				stroke.Color = Color3.fromRGB(0, 120, 40)
			else
				btn.Text = text .. " | OFF"
				btn.TextColor3 = Color3.fromRGB(255, 55, 55)
				btn.BackgroundColor3 = Color3.fromRGB(20, 5, 5)
				stroke.Color = Color3.fromRGB(90, 0, 0)
			end
			callback(on)
		end
		toggleRegistry[text] = setState
		btn.MouseButton1Click:Connect(function() setState(not on) end)
		return setState
	end

	local function setToggle(name, state)
		local setter = toggleRegistry[name]
		if setter then setter(state) end
	end

		setActivePage("FUN")
	createToggle("Fly", function(s) if s then startFly() else stopFly() end end)
	createToggle("Anti Fling", function(s)
		antiFlingEnabled = s
		if s then startAntiFling() else stopAntiFling() end
	end)
	createToggle("Invincible", function(s) godmode = s end)
	createToggle("Invisible", function(s) invisible = s setInvisible(s) end)
	createToggle("Noclip", function(s) noclip = s end)
	createToggle("Crosshair RGB", function(s) crosshairEnabled = s CrosshairDot.Visible = s end)
	createToggle("Skin RGB", function(s) rgb = s if s then startRGB() else stopRGB() end end)
	createToggle("Click TP", function(s) clickTP = s if s then startClickTP() else stopClickTP() end end)
	createToggle("Pseudo Glitch", function(s) nameGlitch = s if s then startNameGlitch() else stopNameGlitch() end end)
	createToggle("Infinite Jump", function(s) infiniteJump = s if s then startInfiniteJump() else stopInfiniteJump() end end)
	createToggle("No Fall Damage", function(s) noFallDamage = s if s then startNoFallDamage() else stopNoFallDamage() end end)
	createToggle("Anti-AFK", function(s) antiAFK = s if s then startAntiAFK() else stopAntiAFK() end end)
	createToggle("Ragdoll", function(s) ragdoll = s if s then startRagdoll() else stopRagdoll() end end)
	createToggle("Force x1000", function(s)
		superForce = s
		local char = getChar()
		if char then setupSuperForce(char) end
	end)

	setActivePage("PVP")
	createToggle("Aimbot", function(s) aimbot = s end)
	createToggle("AIMSCOPE", function(s) aimScope = s end)
	createToggle("FOV Circle", function(s) fovEnabled = s FOVCircle.Visible = s end)
	createToggle("ESP Rouge", function(s) esp = s updateESP() end)
	createToggle("ESP Box RGB + Ligne + Vie", function(s) boxESP=s if s then startBoxESP() else stopBoxESP() end end)
	createToggle("ESP Squelette", function(s) skeletonESP = s if s then startSkeletonESP() else stopSkeletonESP() end end)
	createToggle("Team Check", function(s)
		teamCheckEnabled = s
		if s then
			for _, plr in ipairs(Players:GetPlayers()) do
				if plr ~= player and isTeammate(plr) then
					removeVisibilityESP(plr)
				end
			end
		end
	end)
	createToggle("Visibility Check", function(s)
		visibilityCheckEnabled = s
		for _, obj in pairs(VisibilityESP) do
			if obj.highlight then obj.highlight.Enabled = s end
		end
		if s then updateVisibilityESP() end
	end)
	createToggle("Autoclick", function(s) autoClick = s if s then startAutoClick() else stopAutoClick() end end)

	setActivePage("RAGEBAIT")
	createToggle("Toupie", function(s) spinning = s if s then startSpin() else stopSpin() end end)
	createToggle("Toupie 90°", function(s) spinning90 = s if s then startSpin90() else stopSpin90() end end)
	createToggle("Fake Lag TP", function(s) fakeLagTP = s if s then startFakeLagTP() else stopFakeLagTP() end end)
	createToggle("Fake Lag Angles", function(s) fakeLagAngles = s if s then startFakeLagAngles() else stopFakeLagAngles() end end)
	createToggle("Glue", function(s) glue = s if s then startGlue() else stopGlue() end end)

	setActivePage("ONLY YOUR EYES")
	createToggle("Big Head", function(s) bigHeadEnabled = s updateCharacterVisuals() end)
	createToggle("Tiny Character", function(s) tinyCharacterEnabled = s updateCharacterVisuals() end)
	createToggle("Headless Effect", function(s) headlessEnabled = s updateCharacterVisuals() end)
	createToggle("Bring All", function(s) bringAll = s if s then startBringAll() else stopBringAll() end end)
	createToggle("Kill Aura", function(s) killAura = s if s then startKillAura() else stopKillAura() end end)
	createToggle("Move Objects", function(s) moveObjects = s if s then startMoveObjects() else stopMoveObjects() end end)

	local function createBigBtn(text, color, callback)
		local b = Instance.new("TextButton")
		b.Size = UDim2.new(1, -10, 0, 34)
		b.BackgroundColor3 = color
		b.Text = text
		b.TextColor3 = Color3.fromRGB(255, 55, 55)
		b.Font = Enum.Font.GothamBold
		b.TextSize = 13
		b.TextTransparency = 0
		b.TextStrokeTransparency = 0
		b.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		b.TextXAlignment = Enum.TextXAlignment.Center
		b.TextYAlignment = Enum.TextYAlignment.Center
		b.BackgroundTransparency = 0.58
		b.BorderSizePixel = 0
		b.AutoButtonColor = false
		b.ZIndex = 20
		b.Parent = activePage
		table.insert(searchTargets, {button = b, text = text})
		Instance.new("UICorner", b).CornerRadius = UDim.new(0, 6)
		b.MouseButton1Click:Connect(callback)
	end

	-- Fenêtres Liste / TP / Spectate
	local ListFrame = Instance.new("Frame")
	ListFrame.Size = UDim2.new(0, 300, 0, 380)
	ListFrame.Position = UDim2.new(0.5, -460, 0.2, 0)
	ListFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
	ListFrame.Visible = false
	ListFrame.Active = true
	ListFrame.Draggable = true
	ListFrame.Parent = ScreenGui
	Instance.new("UICorner", ListFrame).CornerRadius = UDim.new(0, 10)
	Instance.new("UIStroke", ListFrame).Color = Color3.fromRGB(160, 0, 0)

	local ListTitle = Instance.new("TextLabel")
	ListTitle.Size = UDim2.new(1, -40, 0, 40)
	ListTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	ListTitle.Text = "YM TOOL  |  JOUEURS"
	ListTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
	ListTitle.Font = Enum.Font.GothamBlack
	ListTitle.TextSize = 15
	ListTitle.Parent = ListFrame
	Instance.new("UICorner", ListTitle).CornerRadius = UDim.new(0, 10)

	local CloseList = Instance.new("TextButton")
	CloseList.Size = UDim2.new(0, 40, 0, 40)
	CloseList.Position = UDim2.new(1, -40, 0, 0)
	CloseList.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	CloseList.Text = "X"
	CloseList.TextColor3 = Color3.fromRGB(255, 255, 255)
	CloseList.Font = Enum.Font.GothamBlack
	CloseList.TextSize = 18
	CloseList.Parent = ListFrame
	Instance.new("UICorner", CloseList).CornerRadius = UDim.new(0, 10)
	CloseList.MouseButton1Click:Connect(function() ListFrame.Visible = false end)

	local RefreshList = Instance.new("TextButton")
	RefreshList.Size = UDim2.new(0.9, 0, 0, 28)
	RefreshList.Position = UDim2.new(0.05, 0, 0, 48)
	RefreshList.BackgroundColor3 = Color3.fromRGB(90, 0, 0)
	RefreshList.Text = "🔄 Actualiser"
	RefreshList.TextColor3 = Color3.fromRGB(255, 220, 220)
	RefreshList.Font = Enum.Font.GothamBold
	RefreshList.TextSize = 13
	RefreshList.Parent = ListFrame
	Instance.new("UICorner", RefreshList).CornerRadius = UDim.new(0, 5)

	local ListScroll = Instance.new("ScrollingFrame")
	ListScroll.Size = UDim2.new(0.9, 0, 0, 290)
	ListScroll.Position = UDim2.new(0.05, 0, 0, 85)
	ListScroll.BackgroundColor3 = Color3.fromRGB(15, 5, 5)
	ListScroll.ScrollBarThickness = 5
	ListScroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
	ListScroll.Parent = ListFrame
	Instance.new("UICorner", ListScroll).CornerRadius = UDim.new(0, 6)
	Instance.new("UIListLayout", ListScroll).Padding = UDim.new(0, 5)

	local function refreshPlayerList()
		for _, c in pairs(ListScroll:GetChildren()) do if c:IsA("Frame") then c:Destroy() end end
		for _, plr in ipairs(Players:GetPlayers()) do
			local row = Instance.new("Frame")
			row.Size = UDim2.new(1, -8, 0, 48)
			row.BackgroundColor3 = Color3.fromRGB(25, 8, 8)
			row.Parent = ListScroll
			Instance.new("UICorner", row).CornerRadius = UDim.new(0, 5)
			local nameL = Instance.new("TextLabel")
			nameL.Size = UDim2.new(1, -10, 0, 22)
			nameL.Position = UDim2.new(0, 6, 0, 3)
			nameL.BackgroundTransparency = 1
			nameL.Text = plr.DisplayName .. "  (@" .. plr.Name .. ")"
			nameL.TextColor3 = Color3.fromRGB(255, 200, 200)
			nameL.Font = Enum.Font.GothamBold
			nameL.TextSize = 13
			nameL.TextXAlignment = Enum.TextXAlignment.Left
			nameL.Parent = row
			local infoL = Instance.new("TextLabel")
			infoL.Size = UDim2.new(1, -10, 0, 18)
			infoL.Position = UDim2.new(0, 6, 0, 26)
			infoL.BackgroundTransparency = 1
			infoL.Text = "ID: " .. plr.UserId .. "  |  Âge: " .. plr.AccountAge .. "j"
			infoL.TextColor3 = Color3.fromRGB(180, 120, 120)
			infoL.Font = Enum.Font.Gotham
			infoL.TextSize = 12
			infoL.TextXAlignment = Enum.TextXAlignment.Left
			infoL.Parent = row
		end
	end
	RefreshList.MouseButton1Click:Connect(refreshPlayerList)

	local TPFrame = Instance.new("Frame")
	TPFrame.Size = UDim2.new(0, 280, 0, 360)
	TPFrame.Position = UDim2.new(0.5, 170, 0.2, 0)
	TPFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
	TPFrame.Visible = false
	TPFrame.Active = true
	TPFrame.Draggable = true
	TPFrame.Parent = ScreenGui
	Instance.new("UICorner", TPFrame).CornerRadius = UDim.new(0, 10)
	Instance.new("UIStroke", TPFrame).Color = Color3.fromRGB(160, 0, 0)

	local TPTitle = Instance.new("TextLabel")
	TPTitle.Size = UDim2.new(1, -40, 0, 40)
	TPTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	TPTitle.Text = "YM TOOL  |  TP"
	TPTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
	TPTitle.Font = Enum.Font.GothamBlack
	TPTitle.TextSize = 15
	TPTitle.Parent = TPFrame
	Instance.new("UICorner", TPTitle).CornerRadius = UDim.new(0, 10)

	local CloseTP = Instance.new("TextButton")
	CloseTP.Size = UDim2.new(0, 40, 0, 40)
	CloseTP.Position = UDim2.new(1, -40, 0, 0)
	CloseTP.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	CloseTP.Text = "X"
	CloseTP.TextColor3 = Color3.fromRGB(255, 255, 255)
	CloseTP.Font = Enum.Font.GothamBlack
	CloseTP.TextSize = 18
	CloseTP.Parent = TPFrame
	Instance.new("UICorner", CloseTP).CornerRadius = UDim.new(0, 10)
	CloseTP.MouseButton1Click:Connect(function() TPFrame.Visible = false end)

	local RefreshTP = Instance.new("TextButton")
	RefreshTP.Size = UDim2.new(0.9, 0, 0, 28)
	RefreshTP.Position = UDim2.new(0.05, 0, 0, 48)
	RefreshTP.BackgroundColor3 = Color3.fromRGB(90, 0, 0)
	RefreshTP.Text = "🔄 Actualiser"
	RefreshTP.TextColor3 = Color3.fromRGB(255, 220, 220)
	RefreshTP.Font = Enum.Font.GothamBold
	RefreshTP.TextSize = 13
	RefreshTP.Parent = TPFrame
	Instance.new("UICorner", RefreshTP).CornerRadius = UDim.new(0, 5)

	local TPScroll = Instance.new("ScrollingFrame")
	TPScroll.Size = UDim2.new(0.9, 0, 0, 270)
	TPScroll.Position = UDim2.new(0.05, 0, 0, 85)
	TPScroll.BackgroundColor3 = Color3.fromRGB(15, 5, 5)
	TPScroll.ScrollBarThickness = 5
	TPScroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
	TPScroll.Parent = TPFrame
	Instance.new("UICorner", TPScroll).CornerRadius = UDim.new(0, 6)
	Instance.new("UIListLayout", TPScroll).Padding = UDim.new(0, 4)

	local function refreshTPList()
		for _, c in pairs(TPScroll:GetChildren()) do if c:IsA("TextButton") then c:Destroy() end end
		for _, plr in ipairs(Players:GetPlayers()) do
			if plr ~= player then
				local btn = Instance.new("TextButton")
				btn.Size = UDim2.new(1, -8, 0, 32)
				btn.BackgroundColor3 = Color3.fromRGB(30, 8, 8)
				btn.Text = plr.DisplayName .. "  (@" .. plr.Name .. ")"
				btn.TextColor3 = Color3.fromRGB(255, 200, 200)
				btn.Font = Enum.Font.GothamBold
				btn.TextSize = 13
				btn.Parent = TPScroll
				Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 5)
				btn.MouseButton1Click:Connect(function() teleportToPlayer(plr) end)
			end
		end
	end
	RefreshTP.MouseButton1Click:Connect(refreshTPList)

	local SpecFrame = Instance.new("Frame")
	SpecFrame.Size = UDim2.new(0, 280, 0, 400)
	SpecFrame.Position = UDim2.new(0.5, 170, 0.18, 0)
	SpecFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
	SpecFrame.Visible = false
	SpecFrame.Active = true
	SpecFrame.Draggable = true
	SpecFrame.Parent = ScreenGui
	Instance.new("UICorner", SpecFrame).CornerRadius = UDim.new(0, 10)
	Instance.new("UIStroke", SpecFrame).Color = Color3.fromRGB(160, 0, 0)

	local SpecTitle = Instance.new("TextLabel")
	SpecTitle.Size = UDim2.new(1, -40, 0, 40)
	SpecTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	SpecTitle.Text = "YM TOOL  |  SPECTATE"
	SpecTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
	SpecTitle.Font = Enum.Font.GothamBlack
	SpecTitle.TextSize = 15
	SpecTitle.Parent = SpecFrame
	Instance.new("UICorner", SpecTitle).CornerRadius = UDim.new(0, 10)

	local CloseSpec = Instance.new("TextButton")
	CloseSpec.Size = UDim2.new(0, 40, 0, 40)
	CloseSpec.Position = UDim2.new(1, -40, 0, 0)
	CloseSpec.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	CloseSpec.Text = "X"
	CloseSpec.TextColor3 = Color3.fromRGB(255, 255, 255)
	CloseSpec.Font = Enum.Font.GothamBlack
	CloseSpec.TextSize = 18
	CloseSpec.Parent = SpecFrame
	Instance.new("UICorner", CloseSpec).CornerRadius = UDim.new(0, 10)
	CloseSpec.MouseButton1Click:Connect(function() SpecFrame.Visible = false end)

	local StopSpecBtn = Instance.new("TextButton")
	StopSpecBtn.Size = UDim2.new(0.9, 0, 0, 32)
	StopSpecBtn.Position = UDim2.new(0.05, 0, 0, 48)
	StopSpecBtn.BackgroundColor3 = Color3.fromRGB(160, 40, 40)
	StopSpecBtn.Text = "⏹ ARRÊTER SPECTATE"
	StopSpecBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
	StopSpecBtn.Font = Enum.Font.GothamBold
	StopSpecBtn.TextSize = 13
	StopSpecBtn.Parent = SpecFrame
	Instance.new("UICorner", StopSpecBtn).CornerRadius = UDim.new(0, 6)
	StopSpecBtn.MouseButton1Click:Connect(stopSpectate)

	local RefreshSpec = Instance.new("TextButton")
	RefreshSpec.Size = UDim2.new(0.9, 0, 0, 28)
	RefreshSpec.Position = UDim2.new(0.05, 0, 0, 88)
	RefreshSpec.BackgroundColor3 = Color3.fromRGB(90, 0, 0)
	RefreshSpec.Text = "🔄 Actualiser"
	RefreshSpec.TextColor3 = Color3.fromRGB(255, 220, 220)
	RefreshSpec.Font = Enum.Font.GothamBold
	RefreshSpec.TextSize = 13
	RefreshSpec.Parent = SpecFrame
	Instance.new("UICorner", RefreshSpec).CornerRadius = UDim.new(0, 5)

	local SpecScroll = Instance.new("ScrollingFrame")
	SpecScroll.Size = UDim2.new(0.9, 0, 0, 265)
	SpecScroll.Position = UDim2.new(0.05, 0, 0, 125)
	SpecScroll.BackgroundColor3 = Color3.fromRGB(15, 5, 5)
	SpecScroll.ScrollBarThickness = 5
	SpecScroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
	SpecScroll.Parent = SpecFrame
	Instance.new("UICorner", SpecScroll).CornerRadius = UDim.new(0, 6)
	Instance.new("UIListLayout", SpecScroll).Padding = UDim.new(0, 4)

	local function refreshSpecList()
		for _, c in pairs(SpecScroll:GetChildren()) do if c:IsA("TextButton") then c:Destroy() end end
		for _, plr in ipairs(Players:GetPlayers()) do
			if plr ~= player then
				local btn = Instance.new("TextButton")
				btn.Size = UDim2.new(1, -8, 0, 32)
				btn.BackgroundColor3 = Color3.fromRGB(30, 8, 8)
				btn.Text = plr.DisplayName .. "  (@" .. plr.Name .. ")"
				btn.TextColor3 = Color3.fromRGB(255, 200, 200)
				btn.Font = Enum.Font.GothamBold
				btn.TextSize = 13
				btn.Parent = SpecScroll
				Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 5)
				btn.MouseButton1Click:Connect(function() spectatePlayer(plr) end)
			end
		end
	end
	RefreshSpec.MouseButton1Click:Connect(refreshSpecList)

	
	-- FLING WINDOW : script séparé lancé depuis BOUTONS
	local flingWindowStop = nil

	local function launchFlingWindow()
	-- Services
	local Players = game:GetService("Players")
	local RunService = game:GetService("RunService")
	local Player = Players.LocalPlayer
	-- GUI Setup
	local ScreenGui = Instance.new("ScreenGui")
	ScreenGui.Name = "KilasikFlingGUI"
	ScreenGui.ResetOnSpawn = false
	ScreenGui.Parent = game:GetService("CoreGui")
	-- Main Frame
	local MainFrame = Instance.new("Frame")
	MainFrame.Size = UDim2.new(0, 300, 0, 350)
	MainFrame.Position = UDim2.new(0.5, -150, 0.5, -175)
	MainFrame.BackgroundColor3 = Color3.fromRGB(15, 5, 5)
	MainFrame.BorderSizePixel = 0
	MainFrame.Active = true
	MainFrame.Draggable = true
	MainFrame.Parent = ScreenGui
	local MainCorner = Instance.new("UICorner")
	MainCorner.CornerRadius = UDim.new(0, 6)
	MainCorner.Parent = MainFrame
	local MainStroke = Instance.new("UIStroke")
	MainStroke.Color = Color3.fromRGB(100, 0, 0)
	MainStroke.Thickness = 1
	MainStroke.Transparency = 0.15
	MainStroke.Parent = MainFrame
	-- Title Bar
	local TitleBar = Instance.new("Frame")
	TitleBar.Size = UDim2.new(1, 0, 0, 30)
	TitleBar.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	TitleBar.BorderSizePixel = 0
	TitleBar.Parent = MainFrame
	local TitleCorner = Instance.new("UICorner")
	TitleCorner.CornerRadius = UDim.new(0, 6)
	TitleCorner.Parent = TitleBar
	-- Title
	local Title = Instance.new("TextLabel")
	Title.Size = UDim2.new(1, -30, 1, 0)
	Title.BackgroundTransparency = 1
	Title.Text = "YM MULTI-FLING"
	Title.TextColor3 = Color3.fromRGB(255, 70, 70)
	Title.Font = Enum.Font.SourceSansBold
	Title.TextSize = 18
	Title.Parent = TitleBar
	-- Close Button
	local CloseButton = Instance.new("TextButton")
	CloseButton.Position = UDim2.new(1, -30, 0, 0)
	CloseButton.Size = UDim2.new(0, 30, 0, 30)
	CloseButton.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	CloseButton.BorderSizePixel = 0
	CloseButton.Text = "X"
	CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	CloseButton.Font = Enum.Font.SourceSansBold
	CloseButton.TextSize = 18
	CloseButton.Parent = TitleBar
	local CloseButtonCorner = Instance.new("UICorner")
	CloseButtonCorner.CornerRadius = UDim.new(0, 4)
	CloseButtonCorner.Parent = CloseButton
	-- Status Label
	local StatusLabel = Instance.new("TextLabel")
	StatusLabel.Position = UDim2.new(0, 10, 0, 40)
	StatusLabel.Size = UDim2.new(1, -20, 0, 25)
	StatusLabel.BackgroundTransparency = 1
	StatusLabel.Text = "Select targets to fling"
	StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	StatusLabel.Font = Enum.Font.SourceSans
	StatusLabel.TextSize = 16
	StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
	StatusLabel.Parent = MainFrame
	-- Player Selection Frame
	local SelectionFrame = Instance.new("Frame")
	SelectionFrame.Position = UDim2.new(0, 10, 0, 70)
	SelectionFrame.Size = UDim2.new(1, -20, 0, 200)
	SelectionFrame.BackgroundColor3 = Color3.fromRGB(10, 3, 3)
	SelectionFrame.BorderSizePixel = 0
	SelectionFrame.Parent = MainFrame
	local SelectionCorner = Instance.new("UICorner")
	SelectionCorner.CornerRadius = UDim.new(0, 4)
	SelectionCorner.Parent = SelectionFrame
	local SelectionStroke = Instance.new("UIStroke")
	SelectionStroke.Color = Color3.fromRGB(70, 0, 0)
	SelectionStroke.Thickness = 1
	SelectionStroke.Transparency = 0.25
	SelectionStroke.Parent = SelectionFrame
	-- Player List ScrollFrame
	local PlayerScrollFrame = Instance.new("ScrollingFrame")
	PlayerScrollFrame.Position = UDim2.new(0, 5, 0, 5)
	PlayerScrollFrame.Size = UDim2.new(1, -10, 1, -10)
	PlayerScrollFrame.BackgroundTransparency = 1
	PlayerScrollFrame.BorderSizePixel = 0
	PlayerScrollFrame.ScrollBarThickness = 6
	PlayerScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
	PlayerScrollFrame.Parent = SelectionFrame
	-- Start Fling Button
	local StartButton = Instance.new("TextButton")
	StartButton.Position = UDim2.new(0, 10, 0, 280)
	StartButton.Size = UDim2.new(0.5, -15, 0, 40)
	StartButton.BackgroundColor3 = Color3.fromRGB(25, 7, 7)
	StartButton.BorderSizePixel = 0
	StartButton.Text = "START FLING"
	StartButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	StartButton.Font = Enum.Font.SourceSansBold
	StartButton.TextSize = 18
	StartButton.Parent = MainFrame
	local StartButtonCorner = Instance.new("UICorner")
	StartButtonCorner.CornerRadius = UDim.new(0, 4)
	StartButtonCorner.Parent = StartButton
	-- Stop Fling Button
	local StopButton = Instance.new("TextButton")
	StopButton.Position = UDim2.new(0.5, 5, 0, 280)
	StopButton.Size = UDim2.new(0.5, -15, 0, 40)
	StopButton.BackgroundColor3 = Color3.fromRGB(110, 0, 0)
	StopButton.BorderSizePixel = 0
	StopButton.Text = "STOP FLING"
	StopButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	StopButton.Font = Enum.Font.SourceSansBold
	StopButton.TextSize = 18
	StopButton.Parent = MainFrame
	local StopButtonCorner = Instance.new("UICorner")
	StopButtonCorner.CornerRadius = UDim.new(0, 4)
	StopButtonCorner.Parent = StopButton
	-- Select/Deselect Buttons
	local SelectAllButton = Instance.new("TextButton")
	SelectAllButton.Position = UDim2.new(0, 10, 0, 330)
	SelectAllButton.Size = UDim2.new(0.5, -15, 0, 30)
	SelectAllButton.BackgroundColor3 = Color3.fromRGB(25, 7, 7)
	SelectAllButton.BorderSizePixel = 0
	SelectAllButton.Text = "SELECT ALL"
	SelectAllButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	SelectAllButton.Font = Enum.Font.SourceSans
	SelectAllButton.TextSize = 14
	SelectAllButton.Parent = MainFrame
	local SelectAllButtonCorner = Instance.new("UICorner")
	SelectAllButtonCorner.CornerRadius = UDim.new(0, 4)
	SelectAllButtonCorner.Parent = SelectAllButton
	local DeselectAllButton = Instance.new("TextButton")
	DeselectAllButton.Position = UDim2.new(0.5, 5, 0, 330)
	DeselectAllButton.Size = UDim2.new(0.5, -15, 0, 30)
	DeselectAllButton.BackgroundColor3 = Color3.fromRGB(25, 7, 7)
	DeselectAllButton.BorderSizePixel = 0
	DeselectAllButton.Text = "DESELECT ALL"
	DeselectAllButton.TextColor3 = Color3.fromRGB(255, 255, 255)
	DeselectAllButton.Font = Enum.Font.SourceSans
	DeselectAllButton.TextSize = 14
	DeselectAllButton.Parent = MainFrame

	for _, button in ipairs({CloseButton, StartButton, StopButton, SelectAllButton, DeselectAllButton}) do
		button.AutoButtonColor = false
		button.MouseEnter:Connect(function()
			button.BackgroundTransparency = 0.12
		end)
		button.MouseLeave:Connect(function()
			button.BackgroundTransparency = 0
		end)
	end
	local DeselectAllButtonCorner = Instance.new("UICorner")
	DeselectAllButtonCorner.CornerRadius = UDim.new(0, 4)
	DeselectAllButtonCorner.Parent = DeselectAllButton
	-- Variables
	local SelectedTargets = {}
	local PlayerCheckboxes = {}
	local FlingActive = false
	local FlingConnection = nil
	getgenv().OldPos = nil
	getgenv().FPDH = workspace.FallenPartsDestroyHeight
	-- Function to update player list
	local function RefreshPlayerList()
	    -- Clear existing player entries
	    for _, child in pairs(PlayerScrollFrame:GetChildren()) do
	        child:Destroy()
	    end
	    PlayerCheckboxes = {}
	    
	    -- Get players and sort them
	    local PlayerList = Players:GetPlayers()
	    table.sort(PlayerList, function(a, b) return a.Name:lower() < b.Name:lower() end)
	    
	    -- Create entries for each player
	    local yPosition = 5
	    for _, player in ipairs(PlayerList) do
	        if player ~= Player then -- Don't include yourself
	            -- Create player entry frame
	            local PlayerEntry = Instance.new("Frame")
	            PlayerEntry.Size = UDim2.new(1, -10, 0, 30)
	            PlayerEntry.Position = UDim2.new(0, 5, 0, yPosition)
	            PlayerEntry.BackgroundColor3 = Color3.fromRGB(20, 5, 5)
	            PlayerEntry.BorderSizePixel = 0
	            PlayerEntry.Parent = PlayerScrollFrame
	            
	            -- Create checkbox
	            local Checkbox = Instance.new("TextButton")
	            Checkbox.Size = UDim2.new(0, 24, 0, 24)
	            Checkbox.Position = UDim2.new(0, 3, 0.5, -12)
	            Checkbox.BackgroundColor3 = Color3.fromRGB(25, 8, 8)
	            Checkbox.BorderSizePixel = 0
	            Checkbox.Text = ""
	            Checkbox.Parent = PlayerEntry
	            
	            -- Checkmark (initially invisible)
	            local Checkmark = Instance.new("TextLabel")
	            Checkmark.Size = UDim2.new(1, 0, 1, 0)
	            Checkmark.BackgroundTransparency = 1
	            Checkmark.Text = "✓"
	            Checkmark.TextColor3 = Color3.fromRGB(0, 255, 0)
	            Checkmark.TextSize = 18
	            Checkmark.Font = Enum.Font.SourceSansBold
	            Checkmark.Visible = SelectedTargets[player.Name] ~= nil
	            Checkmark.Parent = Checkbox
	            
	            -- Player name label
	            local NameLabel = Instance.new("TextLabel")
	            NameLabel.Size = UDim2.new(1, -35, 1, 0)
	            NameLabel.Position = UDim2.new(0, 30, 0, 0)
	            NameLabel.BackgroundTransparency = 1
	            NameLabel.Text = player.Name
	            NameLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	            NameLabel.TextSize = 16
	            NameLabel.Font = Enum.Font.SourceSans
	            NameLabel.TextXAlignment = Enum.TextXAlignment.Left
	            NameLabel.Parent = PlayerEntry
	            
	            -- Make entire entry clickable
	            local ClickArea = Instance.new("TextButton")
	            ClickArea.Size = UDim2.new(1, 0, 1, 0)
	            ClickArea.BackgroundTransparency = 1
	            ClickArea.Text = ""
	            ClickArea.ZIndex = 2
	            ClickArea.Parent = PlayerEntry
	            
	            -- Selection toggle on click
	            ClickArea.MouseButton1Click:Connect(function()
	                if SelectedTargets[player.Name] then
	                    SelectedTargets[player.Name] = nil
	                    Checkmark.Visible = false
	                else
	                    SelectedTargets[player.Name] = player
	                    Checkmark.Visible = true
	                end
	                
	                UpdateStatus()
	            end)
	            
	            -- Store reference to this player's UI
	            PlayerCheckboxes[player.Name] = {
	                Entry = PlayerEntry,
	                Checkmark = Checkmark
	            }
	            
	            yPosition = yPosition + 35
	        end
	    end
	    
	    -- Update scrollframe canvas size
	    PlayerScrollFrame.CanvasSize = UDim2.new(0, 0, 0, yPosition + 5)
	end
	-- Count selected targets
	local function CountSelectedTargets()
	    local count = 0
	    for _ in pairs(SelectedTargets) do
	        count = count + 1
	    end
	    return count
	end
	-- Update status display
	local function UpdateStatus()
	    local count = CountSelectedTargets()
	    if FlingActive then
	        StatusLabel.Text = "Flinging " .. count .. " target(s)"
	        StatusLabel.TextColor3 = Color3.fromRGB(255, 80, 80)
	    else
	        StatusLabel.Text = count .. " target(s) selected" 
	        StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	    end
	end
	-- Function to select/deselect all players
	local function ToggleAllPlayers(select)
	    for _, player in ipairs(Players:GetPlayers()) do
	        if player ~= Player then
	            local checkboxData = PlayerCheckboxes[player.Name]
	            if checkboxData then
	                if select then
	                    SelectedTargets[player.Name] = player
	                    checkboxData.Checkmark.Visible = true
	                else
	                    SelectedTargets[player.Name] = nil
	                    checkboxData.Checkmark.Visible = false
	                end
	            end
	        end
	    end
	    
	    UpdateStatus()
	end
	-- Show notification
	local function Message(Title, Text, Time)
	    game:GetService("StarterGui"):SetCore("SendNotification", {
	        Title = Title,
	        Text = Text,
	        Duration = Time or 5
	    })
	end
	-- The fling function from zqyDSUWX
	local function SkidFling(TargetPlayer)
	    local Character = Player.Character
	    local Humanoid = Character and Character:FindFirstChildOfClass("Humanoid")
	    local RootPart = Humanoid and Humanoid.RootPart
	    local TCharacter = TargetPlayer.Character
	    if not TCharacter then return end
	    
	    local THumanoid
	    local TRootPart
	    local THead
	    local Accessory
	    local Handle
	    if TCharacter:FindFirstChildOfClass("Humanoid") then
	        THumanoid = TCharacter:FindFirstChildOfClass("Humanoid")
	    end
	    if THumanoid and THumanoid.RootPart then
	        TRootPart = THumanoid.RootPart
	    end
	    if TCharacter:FindFirstChild("Head") then
	        THead = TCharacter.Head
	    end
	    if TCharacter:FindFirstChildOfClass("Accessory") then
	        Accessory = TCharacter:FindFirstChildOfClass("Accessory")
	    end
	    if Accessory and Accessory:FindFirstChild("Handle") then
	        Handle = Accessory.Handle
	    end
	    if Character and Humanoid and RootPart then
	        if RootPart.Velocity.Magnitude < 50 then
	            getgenv().OldPos = RootPart.CFrame
	        end
	        
	        if THumanoid and THumanoid.Sit then
	            return Message("Error", TargetPlayer.Name .. " is sitting", 2)
	        end
	        
	        if THead then
	            workspace.CurrentCamera.CameraSubject = THead
	        elseif Handle then
	            workspace.CurrentCamera.CameraSubject = Handle
	        elseif THumanoid and TRootPart then
	            workspace.CurrentCamera.CameraSubject = THumanoid
	        end
	        
	        if not TCharacter:FindFirstChildWhichIsA("BasePart") then
	            return
	        end
	        
	        local FPos = function(BasePart, Pos, Ang)
	            RootPart.CFrame = CFrame.new(BasePart.Position) * Pos * Ang
	            Character:SetPrimaryPartCFrame(CFrame.new(BasePart.Position) * Pos * Ang)
	            RootPart.Velocity = Vector3.new(9e7, 9e7 * 10, 9e7)
	            RootPart.RotVelocity = Vector3.new(9e8, 9e8, 9e8)
	        end
	        
	        local SFBasePart = function(BasePart)
	            local TimeToWait = 2
	            local Time = tick()
	            local Angle = 0
	            repeat
	                if RootPart and THumanoid then
	                    if BasePart.Velocity.Magnitude < 50 then
	                        Angle = Angle + 100
	                        FPos(BasePart, CFrame.new(0, 1.5, 0) + THumanoid.MoveDirection * BasePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(Angle),0 ,0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0) + THumanoid.MoveDirection * BasePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(Angle), 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, 1.5, 0) + THumanoid.MoveDirection * BasePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(Angle),0 ,0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0) + THumanoid.MoveDirection * BasePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(Angle), 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, 1.5, 0) + THumanoid.MoveDirection, CFrame.Angles(math.rad(Angle),0 ,0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0) + THumanoid.MoveDirection, CFrame.Angles(math.rad(Angle), 0, 0))
	                        task.wait()
	                    else
	                        FPos(BasePart, CFrame.new(0, 1.5, THumanoid.WalkSpeed), CFrame.Angles(math.rad(90), 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, -THumanoid.WalkSpeed), CFrame.Angles(0, 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, 1.5, THumanoid.WalkSpeed), CFrame.Angles(math.rad(90), 0, 0))
	                        task.wait()
	                        
	                        FPos(BasePart, CFrame.new(0, -1.5, 0), CFrame.Angles(math.rad(90), 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0), CFrame.Angles(0, 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0), CFrame.Angles(math.rad(90), 0, 0))
	                        task.wait()
	                        FPos(BasePart, CFrame.new(0, -1.5, 0), CFrame.Angles(0, 0, 0))
	                        task.wait()
	                    end
	                end
	            until Time + TimeToWait < tick() or not FlingActive
	        end
	        
	        workspace.FallenPartsDestroyHeight = 0/0
	        
	        local BV = Instance.new("BodyVelocity")
	        BV.Parent = RootPart
	        BV.Velocity = Vector3.new(0, 0, 0)
	        BV.MaxForce = Vector3.new(9e9, 9e9, 9e9)
	        
	        Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
	        
	        if TRootPart then
	            SFBasePart(TRootPart)
	        elseif THead then
	            SFBasePart(THead)
	        elseif Handle then
	            SFBasePart(Handle)
	        else
	            return Message("Error", TargetPlayer.Name .. " has no valid parts", 2)
	        end
	        
	        BV:Destroy()
	        Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
	        workspace.CurrentCamera.CameraSubject = Humanoid
	        
	        -- Reset character position
	        if getgenv().OldPos then
	            repeat
	                RootPart.CFrame = getgenv().OldPos * CFrame.new(0, .5, 0)
	                Character:SetPrimaryPartCFrame(getgenv().OldPos * CFrame.new(0, .5, 0))
	                Humanoid:ChangeState("GettingUp")
	                for _, part in pairs(Character:GetChildren()) do
	                    if part:IsA("BasePart") then
	                        part.Velocity, part.RotVelocity = Vector3.new(), Vector3.new()
	                    end
	                end
	                task.wait()
	            until (RootPart.Position - getgenv().OldPos.p).Magnitude < 25
	            workspace.FallenPartsDestroyHeight = getgenv().FPDH
	        end
	    else
	        return Message("Error", "Your character is not ready", 2)
	    end
	end
	-- Start flinging selected targets
	local function StartFling()
	    if FlingActive then return end
	    
	    local count = CountSelectedTargets()
	    if count == 0 then
	        StatusLabel.Text = "No targets selected!"
	        wait(1)
	        StatusLabel.Text = "Select targets to fling"
	        return
	    end
	    
	    FlingActive = true
	    UpdateStatus()
	    Message("Started", "Flinging " .. count .. " targets", 2)
	    
	    -- Start flinger in separate thread
	    spawn(function()
	        while FlingActive do
	            local validTargets = {}
	            
	            -- Process all targets first to determine which are valid
	            for name, player in pairs(SelectedTargets) do
	                if player and player.Parent then
	                    validTargets[name] = player
	                else
	                    -- Remove players who left
	                    SelectedTargets[name] = nil
	                    local checkbox = PlayerCheckboxes[name]
	                    if checkbox then
	                        checkbox.Checkmark.Visible = false
	                    end
	                end
	            end
	            
	            -- Then attempt to fling each valid target
	            for _, player in pairs(validTargets) do
	                if FlingActive then
	                    SkidFling(player)
	                    -- Brief wait between targets to allow movement to reset
	                    wait(0.1)
	                else
	                    break
	                end
	            end
	            
	            -- Update status periodically
	            UpdateStatus()
	            
	            -- Wait a moment before starting next fling cycle
	            wait(0.5)
	        end
	    end)
	end
	-- Stop flinging
	local function StopFling()
	    if not FlingActive then return end
	    
	    FlingActive = false
	    
	    UpdateStatus()
	    Message("Stopped", "Fling has been stopped", 2)
	end
	-- Set up button connections
	StartButton.MouseButton1Click:Connect(StartFling)
	StopButton.MouseButton1Click:Connect(StopFling)
	SelectAllButton.MouseButton1Click:Connect(function() ToggleAllPlayers(true) end)
	DeselectAllButton.MouseButton1Click:Connect(function() ToggleAllPlayers(false) end)
	CloseButton.MouseButton1Click:Connect(function()
	    StopFling()
	    ScreenGui:Destroy()
	end)
	-- Handle player joining/leaving
	Players.PlayerAdded:Connect(RefreshPlayerList)
	Players.PlayerRemoving:Connect(function(player)
	    if SelectedTargets[player.Name] then
	        SelectedTargets[player.Name] = nil
	    end
	    RefreshPlayerList()
	    UpdateStatus()
	end)
	-- Initialize
	RefreshPlayerList()
	UpdateStatus()
	-- Success message
	Message("Loaded", "YM MULTI-FLING loaded!", 3)
		return function()
			pcall(function() StopFling() end)
			pcall(function() ScreenGui:Destroy() end)
		end
	end

	setActivePage("BOUTONS")

	createBigBtn("YM FLING", Color3.fromRGB(110, 0, 0), function()
		if flingWindowStop then
			pcall(flingWindowStop)
			flingWindowStop = nil
		end
		flingWindowStop = launchFlingWindow()
	end)

	createBigBtn("📋 LISTE DES JOUEURS", Color3.fromRGB(90, 0, 0), function()
		ListFrame.Visible = not ListFrame.Visible
		if ListFrame.Visible then refreshPlayerList() end
	end)
	createBigBtn("📍 TP SUR UN JOUEUR", Color3.fromRGB(110, 0, 0), function()
		TPFrame.Visible = not TPFrame.Visible
		if TPFrame.Visible then refreshTPList() end
	end)
	createBigBtn("👁 SPECTATE JOUEUR", Color3.fromRGB(80, 20, 120), function()
		SpecFrame.Visible = not SpecFrame.Visible
		if SpecFrame.Visible then refreshSpecList() end
	end)

	createBigBtn("🛠 DEBUG", Color3.fromRGB(90, 0, 0), function()
		DebugFrame.Visible = not DebugFrame.Visible
		debugVisible = DebugFrame.Visible
	end)

	-- =====================================================
	-- PRESETS RAPIDES
	-- Les presets pilotent les vrais toggles existants.
	-- =====================================================
	local function applyToggleSet(map)
		for name, state in pairs(map) do
			setToggle(name, state)
		end
	end

	local presetPage = pages["PRESET"]
	local presetStates = {}
	local presetCards = {}

	local function addPresetCard(name, description, onApply, offApply)
		local card = Instance.new("Frame")
		card.Size = UDim2.new(1, -10, 0, 82)
		card.BackgroundColor3 = Color3.fromRGB(18, 5, 5)
		card.BackgroundTransparency = 0.15
		card.BorderSizePixel = 0
		card.ZIndex = 20
		card.Parent = presetPage
		Instance.new("UICorner", card).CornerRadius = UDim.new(0, 8)
		local stroke = Instance.new("UIStroke")
		stroke.Color = Color3.fromRGB(90, 0, 0)
		stroke.Parent = card

		local button = Instance.new("TextButton")
		button.Size = UDim2.new(1, -20, 0, 38)
		button.Position = UDim2.fromOffset(10, 8)
		button.BackgroundColor3 = Color3.fromRGB(28, 7, 7)
		button.BackgroundTransparency = 0.05
		button.Text = name .. " | OFF"
		button.TextColor3 = Color3.fromRGB(255, 70, 70)
		button.Font = Enum.Font.GothamBlack
		button.TextSize = 13
		button.AutoButtonColor = false
		button.ZIndex = 21
		button.Parent = card
		Instance.new("UICorner", button).CornerRadius = UDim.new(0, 6)

		local tip = Instance.new("TextLabel")
		tip.Size = UDim2.new(1, -20, 0, 25)
		tip.Position = UDim2.fromOffset(10, 49)
		tip.BackgroundTransparency = 1
		tip.Text = description
		tip.TextColor3 = Color3.fromRGB(190, 150, 150)
		tip.Font = Enum.Font.Gotham
		tip.TextSize = 11
		tip.TextXAlignment = Enum.TextXAlignment.Left
		tip.TextTruncate = Enum.TextTruncate.AtEnd
		tip.Visible = false
		tip.ZIndex = 22
		tip.Parent = card

		local state = false
		presetStates[name] = function(value)
			value = value == true
			if state == value then return end
			state = value
			if state then
				button.Text = name .. " | ON"
				button.TextColor3 = Color3.fromRGB(90, 255, 120)
				button.BackgroundColor3 = Color3.fromRGB(10, 35, 15)
				stroke.Color = Color3.fromRGB(0, 120, 40)
				onApply()
			else
				button.Text = name .. " | OFF"
				button.TextColor3 = Color3.fromRGB(255, 70, 70)
				button.BackgroundColor3 = Color3.fromRGB(28, 7, 7)
				stroke.Color = Color3.fromRGB(90, 0, 0)
				offApply()
			end
		end

		button.MouseButton1Click:Connect(function() presetStates[name](not state) end)
		button.MouseEnter:Connect(function() tip.Visible = true end)
		button.MouseLeave:Connect(function() tip.Visible = false end)
		presetCards[name] = button
	end

	addPresetCard("PRESET RGB", "Crosshair RGB + Skin RGB + ESP Box RGB + FOV RGB + Pseudo Glitch",
		function()
			applyToggleSet({
				["Crosshair RGB"] = true,
				["Skin RGB"] = true,
				["ESP Box RGB + Ligne + Vie"] = true,
				["FOV Circle"] = true,
				["Pseudo Glitch"] = true,
			})
		end,
		function()
			applyToggleSet({["Crosshair RGB"] = false,["Skin RGB"] = false,["ESP Box RGB + Ligne + Vie"] = false,["FOV Circle"] = false,["Pseudo Glitch"] = false})
		end)

	addPresetCard("PRESET PVP", "AIMSCOPE + FOV + ESP Box RGB + Squelette + Visibility + Autoclick + Anti Fling",
		function()
			applyToggleSet({
				["Aimbot"] = false, ["ESP Rouge"] = false, ["Team Check"] = false,
				["AIMSCOPE"] = true, ["FOV Circle"] = true,
				["ESP Box RGB + Ligne + Vie"] = true, ["ESP Squelette"] = true,
				["Visibility Check"] = true, ["Autoclick"] = true, ["Anti Fling"] = true,
			})
		end,
		function()
			applyToggleSet({["AIMSCOPE"] = false,["FOV Circle"] = false,["ESP Box RGB + Ligne + Vie"] = false,["ESP Squelette"] = false,["Visibility Check"] = false,["Autoclick"] = false,["Anti Fling"] = false})
		end)

	addPresetCard("PRESET RAGEBAIT", "Toupie + Fake Lag TP + ouvre la fenêtre YM FLING",
		function()
			applyToggleSet({["Toupie"] = true, ["Fake Lag TP"] = true})
			if flingWindowStop then pcall(flingWindowStop) end
			flingWindowStop = launchFlingWindow()
		end,
		function()
			applyToggleSet({["Toupie"] = false, ["Fake Lag TP"] = false})
			if flingWindowStop then pcall(flingWindowStop); flingWindowStop = nil end
		end)

	addPresetCard("PRESET FUN", "Fly + Toupie + Invisible + Pseudo Glitch + Noclip + Force x1000 + Anti-AFK",
		function()
			applyToggleSet({
				["Fly"] = true, ["Toupie"] = true, ["Invisible"] = true,
				["Pseudo Glitch"] = true, ["Noclip"] = true, ["Force x1000"] = true, ["Anti-AFK"] = true,
			})
		end,
		function()
			applyToggleSet({["Fly"] = false,["Toupie"] = false,["Invisible"] = false,["Pseudo Glitch"] = false,["Noclip"] = false,["Force x1000"] = false,["Anti-AFK"] = false})
		end)

	-- Fenêtre WAYPOINTS ajoutée sans modifier les fenêtres existantes
	WaypointFrame = Instance.new("Frame")
	WaypointFrame.Size = UDim2.new(0, 330, 0, 330)
	WaypointFrame.Position = UDim2.new(0.5, 165, 0.15, 0)
	WaypointFrame.BackgroundColor3 = Color3.fromRGB(8, 8, 10)
	WaypointFrame.Visible = false
	WaypointFrame.Active = true
	WaypointFrame.Draggable = true
	WaypointFrame.Parent = ScreenGui
	Instance.new("UICorner", WaypointFrame).CornerRadius = UDim.new(0, 10)
	Instance.new("UIStroke", WaypointFrame).Color = Color3.fromRGB(160, 0, 0)

	local WaypointTitle = Instance.new("TextLabel")
	WaypointTitle.Size = UDim2.new(1, -40, 0, 40)
	WaypointTitle.BackgroundColor3 = Color3.fromRGB(18, 0, 0)
	WaypointTitle.Text = "YM TOOL  |  WAYPOINTS"
	WaypointTitle.TextColor3 = Color3.fromRGB(220, 20, 20)
	WaypointTitle.Font = Enum.Font.GothamBlack
	WaypointTitle.TextSize = 15
	WaypointTitle.Parent = WaypointFrame
	Instance.new("UICorner", WaypointTitle).CornerRadius = UDim.new(0, 10)

	local WaypointClose = Instance.new("TextButton")
	WaypointClose.Size = UDim2.fromOffset(40, 40)
	WaypointClose.Position = UDim2.new(1, -40, 0, 0)
	WaypointClose.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
	WaypointClose.Text = "X"
	WaypointClose.TextColor3 = Color3.fromRGB(255,255,255)
	WaypointClose.Font = Enum.Font.GothamBlack
	WaypointClose.TextSize = 17
	WaypointClose.Parent = WaypointFrame
	Instance.new("UICorner", WaypointClose).CornerRadius = UDim.new(0, 10)
	WaypointClose.MouseButton1Click:Connect(function() WaypointFrame.Visible = false end)

	for i = 1, 6 do
		local y = 48 + (i - 1) * 44
		local box = Instance.new("TextBox")
		box.Size = UDim2.new(0, 125, 0, 32)
		box.Position = UDim2.new(0, 10, 0, y)
		box.BackgroundColor3 = Color3.fromRGB(25, 8, 8)
		box.Text = waypointSlots[i].name
		box.TextColor3 = Color3.fromRGB(255, 220, 220)
		box.Font = Enum.Font.GothamBold
		box.TextSize = 12
		box.ClearTextOnFocus = false
		box.Parent = WaypointFrame
		Instance.new("UICorner", box).CornerRadius = UDim.new(0, 5)
		box.FocusLost:Connect(function()
			if box.Text ~= "" then waypointSlots[i].name = box.Text end
		end)

		local setBtn = Instance.new("TextButton")
		setBtn.Size = UDim2.new(0, 80, 0, 32)
		setBtn.Position = UDim2.new(0, 142, 0, y)
		setBtn.BackgroundColor3 = Color3.fromRGB(110, 0, 0)
		setBtn.Text = "SET"
		setBtn.TextColor3 = Color3.fromRGB(255,255,255)
		setBtn.Font = Enum.Font.GothamBold
		setBtn.TextSize = 12
		setBtn.Parent = WaypointFrame
		Instance.new("UICorner", setBtn).CornerRadius = UDim.new(0, 5)
		setBtn.MouseButton1Click:Connect(function()
			local root = getRoot()
			if root then waypointSlots[i].cframe = root.CFrame end
		end)

		local tpBtn = Instance.new("TextButton")
		tpBtn.Size = UDim2.new(0, 80, 0, 32)
		tpBtn.Position = UDim2.new(0, 228, 0, y)
		tpBtn.BackgroundColor3 = Color3.fromRGB(70, 40, 100)
		tpBtn.Text = "TP"
		tpBtn.TextColor3 = Color3.fromRGB(255,255,255)
		tpBtn.Font = Enum.Font.GothamBold
		tpBtn.TextSize = 12
		tpBtn.Parent = WaypointFrame
		Instance.new("UICorner", tpBtn).CornerRadius = UDim.new(0, 5)
		tpBtn.MouseButton1Click:Connect(function()
			local root = getRoot()
			if root and waypointSlots[i].cframe then root.CFrame = waypointSlots[i].cframe end
		end)
	end

	createBigBtn("📍 WAYPOINTS", Color3.fromRGB(90, 0, 0), function()
		WaypointFrame.Visible = not WaypointFrame.Visible
	end)

	-- Le curseur est forcé uniquement quand la fenêtre PRINCIPALE est visible.
	-- Les fenêtres secondaires (Debug, Joueurs, TP, Spectate, Waypoints)
	-- ne déclenchent plus le forçage du curseur.
	local function updateCursorForWindows()
		setCursorForced(Main.Visible)
	end

	Main:GetPropertyChangedSignal("Visible"):Connect(updateCursorForWindows)
	updateCursorForWindows()

	createBigBtn("👻 CACHER TOUTES LES FENÊTRES", Color3.fromRGB(70, 20, 20), function()
		Main.Visible = false
		DebugFrame.Visible = false
		ListFrame.Visible = false
		TPFrame.Visible = false
		SpecFrame.Visible = false
		WaypointFrame.Visible = false
		guiVisible = false
		debugVisible = false
	end)


		setActivePage("VALEURS MODIFIABLE")

	local function createSpeed(label, default, cb)
		local f = Instance.new("Frame")
		f.Size = UDim2.new(1, -8, 0, 48)
		f.BackgroundTransparency = 1
		f.Parent = activePage
		local l = Instance.new("TextLabel")
		l.Size = UDim2.new(1, 0, 0, 16)
		l.BackgroundTransparency = 1
		l.Text = label
		l.TextColor3 = Color3.fromRGB(200, 160, 160)
		l.Font = Enum.Font.Gotham
		l.TextSize = 12
		l.TextXAlignment = Enum.TextXAlignment.Left
		l.Parent = f
		local box = Instance.new("TextBox")
		box.Size = UDim2.new(0.55, 0, 0, 26)
		box.Position = UDim2.new(0, 0, 0, 18)
		box.BackgroundColor3 = Color3.fromRGB(20, 5, 5)
		box.Text = tostring(default)
		box.TextColor3 = Color3.fromRGB(255, 200, 200)
		box.Font = Enum.Font.GothamBold
		box.TextSize = 13
		box.Parent = f
		Instance.new("UICorner", box).CornerRadius = UDim.new(0, 5)
		local ok = Instance.new("TextButton")
		ok.Size = UDim2.new(0.35, 0, 0, 26)
		ok.Position = UDim2.new(0.6, 0, 0, 18)
		ok.BackgroundColor3 = Color3.fromRGB(140, 0, 0)
		ok.Text = "OK"
		ok.TextColor3 = Color3.fromRGB(255, 255, 255)
		ok.Font = Enum.Font.GothamBold
		ok.TextSize = 12
		ok.Parent = f
		Instance.new("UICorner", ok).CornerRadius = UDim.new(0, 5)
		ok.MouseButton1Click:Connect(function()
			local v = tonumber(box.Text)
			if v then cb(v) end
		end)
	end

	createSpeed("Taille Crosshair", 5, function(v) CrosshairDot.Size = UDim2.fromOffset(math.clamp(math.floor(v), 1, 30), math.clamp(math.floor(v), 1, 30)) end)
	createSpeed("Rayon FOV", 150, function(v) fovRadius = math.clamp(math.floor(v), 20, 600) end)
	createSpeed("Vitesse de marche", 16, setWalkSpeed)
	createSpeed("Vitesse de vol", 50, function(v) flySpeed = v end)
	createSpeed("Vitesse Toupie", 50, function(v) spinSpeed = v end)
	createSpeed("Vitesse Toupie 90°", 5000, function(v) spinSpeed90 = v end)
	createSpeed("Force Power (x1000)", 2800, function(v) forcePower = v end)
	createSpeed("Force de saut", 50, function(v) jumpPower = math.max(0, v) end)
	createSpeed("FPS COUNTER (0 = débride les FPS)", 0, function(v)
		fpsCap = math.max(0, math.floor(v))
		applyFPSCap()
	end)

	UserInputService.InputBegan:Connect(function(i, g)
		if i.UserInputType == Enum.UserInputType.MouseButton2 then
			aiming = true
		end
		if g then return end
		if i.KeyCode == Enum.KeyCode.P then
			-- P masque uniquement la fenêtre principale.
			-- Les fenêtres secondaires (Debug, Joueurs, TP, Spectate, Waypoints)
			-- gardent leur état actuel.
			guiVisible = not guiVisible
			Main.Visible = guiVisible
		end
	end)

	UserInputService.InputEnded:Connect(function(i)
		if i.UserInputType == Enum.UserInputType.MouseButton2 then
			aiming = false
		end
	end)
	end

	buildDirectButtonUI()

	RunService:BindToRenderStep("YM_Aimbot", Enum.RenderPriority.Camera.Value + 1, function()
		local currentCamera = workspace.CurrentCamera
		if currentCamera then Camera = currentCamera end
		if (aimbot or (aimScope and aiming)) and currentCamera then
			local h = getClosestHead()
			if h then
				local cameraPos = currentCamera.CFrame.Position
				currentCamera.CFrame = CFrame.lookAt(cameraPos, h.Position)
				local root = getRoot()
				local flatTarget = Vector3.new(h.Position.X, root and root.Position.Y or cameraPos.Y, h.Position.Z)
				if root and (flatTarget - root.Position).Magnitude > 0.01 then
					root.CFrame = CFrame.lookAt(root.Position, flatTarget)
				end
			end
		end
	end)

	RunService.RenderStepped:Connect(function()
		if flying and bodyVelocity and bodyGyro then
			local m = Vector3.zero
			if UserInputService:IsKeyDown(Enum.KeyCode.W) then m += Camera.CFrame.LookVector end
			if UserInputService:IsKeyDown(Enum.KeyCode.S) then m -= Camera.CFrame.LookVector end
			if UserInputService:IsKeyDown(Enum.KeyCode.A) then m -= Camera.CFrame.RightVector end
			if UserInputService:IsKeyDown(Enum.KeyCode.D) then m += Camera.CFrame.RightVector end
			if UserInputService:IsKeyDown(Enum.KeyCode.Space) then m += Vector3.new(0, 1, 0) end
			if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then m -= Vector3.new(0, 1, 0) end
			bodyVelocity.Velocity = m.Magnitude > 0 and m.Unit * flySpeed or Vector3.zero
			bodyGyro.CFrame = Camera.CFrame
		end
	end)

	RunService.Heartbeat:Connect(function()
		local hum, char = getHumanoid(), getChar()
		if not hum or not char then return end
		-- Ne pas casser le sprint natif du jeu : si le jeu augmente la vitesse
		-- au-dessus de notre vitesse de base, on la laisse active. Quand le sprint
		-- s'arrête et que la vitesse revient à la normale, on reprend walkSpeed.
		if hum.WalkSpeed > walkSpeed then
			gameSprintSpeed = hum.WalkSpeed
		elseif hum.WalkSpeed < walkSpeed then
			gameSprintSpeed = nil
			hum.WalkSpeed = walkSpeed
		end
		-- Si un script du jeu a changé la vitesse pendant le sprint, on ne la force pas.
		if gameSprintSpeed and hum.WalkSpeed >= gameSprintSpeed then
			gameSprintSpeed = hum.WalkSpeed
		end
		if hum.UseJumpPower then
			if hum.JumpPower ~= jumpPower then hum.JumpPower = jumpPower end
		else
			if hum.JumpHeight ~= jumpPower / 7 then hum.JumpHeight = jumpPower / 7 end
		end
		if godmode then
			hum.MaxHealth = math.huge
			hum.Health = math.huge
		end
		if noclip then
			for _, p in pairs(char:GetDescendants()) do
				if p:IsA("BasePart") then p.CanCollide = false end
			end
		end
	end)

	Players.PlayerAdded:Connect(function(plr)
		plr.CharacterAdded:Connect(function()
			task.wait(1)
			if esp then createESP(plr) end
		end)
	end)
	Players.PlayerRemoving:Connect(function(plr)
		removeESP(plr)
		if skeletonDrawings[plr] then
			for _, d in pairs(skeletonDrawings[plr]) do if d.Remove then d:Remove() end end
			skeletonDrawings[plr] = nil
		end
	end)

	for _, plr in pairs(Players:GetPlayers()) do
		plr.CharacterAdded:Connect(function()
			task.wait(1)
			if esp then createESP(plr) end
		end)
	end

	player.CharacterAdded:Connect(function(char)
		task.wait(0.8)
		protect()
		setWalkSpeed(walkSpeed)
		setupSuperForce(char)
		if godmode then
			local h = char:WaitForChild("Humanoid")
			h.MaxHealth = math.huge
			h.Health = math.huge
		end
		if invisible then task.wait(0.3) setInvisible(true) end
		if rgb then startRGB() end
		if flying then stopFly() task.wait(0.3) startFly() end
		if spinning90 then stopSpin90() task.wait(0.3) startSpin90() end
		if ragdoll then stopRagdoll() task.wait(0.5) startRagdoll() end
		if nameGlitch then stopNameGlitch() task.wait(0.5) startNameGlitch() end
		characterVisualBackup = {}
		if bigHeadEnabled or tinyCharacterEnabled or headlessEnabled then
			task.wait(0.2)
			updateCharacterVisuals()
		end
	end)

	if player.Character then
		setupSuperForce(player.Character)
	end

	-- Une seule barre de recherche : celle de la cartographie principale.
	-- Elle filtre les boutons déjà enregistrés dans searchTargets.
	SearchBox:GetPropertyChangedSignal("Text"):Connect(function()
		local query = string.lower(SearchBox.Text or "")
		for _, item in ipairs(searchTargets) do
			if query == "" then
				item.button.Visible = true
			else
				item.button.Visible = string.find(string.lower(item.text), query, 1, true) ~= nil
			end
		end
	end)


	showCategory("ACCUEIL")

	-- Fonds des fenêtres : ajoutés une fois toute l'interface créée.
	-- Apparence personnalisée UNIQUEMENT pour la fenêtre principale du tool.
	-- Les fenêtres TP / Spectate / Liste / Waypoints / Debug gardent leur apparence.
	addWindowBackground(Main)

	-- Image des boutons : uniquement dans la fenêtre principale du YM TOOL.
	-- Les fenêtres TP / Waypoints / Spectate / Liste / Debug restent inchangées.
	for _, obj in ipairs(Main:GetDescendants()) do
		if obj:IsA("GuiButton") then
			addButtonBackground(obj)
		end
	end

	print("✅ YM TOOL PC complet + Anti-Detection")
end

local function openDeveloperPrompt()
	PassLabel.Visible = false
	PassBox.Visible = false
	PassBtn.Visible = false
	DevBtn.Visible = false
	ErrorLabel.Visible = false
	StaffFrame.Visible = true
	StaffBox.Text = ""
	StaffError.Text = ""
	task.defer(function() StaffBox:CaptureFocus() end)
end

local function closeDeveloperPrompt()
	StaffFrame.Visible = false
	PassLabel.Visible = true
	PassBox.Visible = true
	PassBtn.Visible = true
	DevBtn.Visible = true
	ErrorLabel.Visible = true
	PassBox.Text = ""
	ErrorLabel.Text = ""
end

local function tryDeveloperPassword()
	if StaffBox.Text == developerPassword then
		loadMainScript()
	else
		StaffError.Text = "Mot de passe développeur incorrect !"
		StaffBox.Text = ""
		task.wait(1.5)
		StaffError.Text = ""
	end
end

DevBtn.MouseButton1Click:Connect(openDeveloperPrompt)
StaffBtn.MouseButton1Click:Connect(tryDeveloperPassword)
StaffBackBtn.MouseButton1Click:Connect(closeDeveloperPrompt)

StaffBox.FocusLost:Connect(function(enter)
	if enter and StaffFrame.Visible then
		tryDeveloperPassword()
	end
end)

PassBtn.MouseButton1Click:Connect(function()
	if PassBox.Text == correctPassword then
		loadMainScript()
	else
		ErrorLabel.Text = "Mot de passe incorrect !"
		PassBox.Text = ""
		task.wait(1.5)
		ErrorLabel.Text = ""
	end
end)

PassBox.FocusLost:Connect(function(enter)
	if enter and not StaffFrame.Visible then
		if PassBox.Text == correctPassword then
			loadMainScript()
		else
			ErrorLabel.Text = "Mot de passe incorrect !"
			PassBox.Text = ""
			task.wait(1.5)
			ErrorLabel.Text = ""
		end
	end
end)

Features & Information

UPDATE ON DISCORD the key : ymclxn

Community Comments (1)

FEMDER2048FEMDER2048Oct 1, 2026

Я когда хочу оплатить выдачи ошибку

More Scripts for Universal Scripts