"-- 获取 CoreGui\r\nlocal CoreGui = game:GetService(\"CoreGui\")\r\n\r\n-- 创建 ScreenGui,并将它添加到 CoreGui 中\r\nlocal screenGui = Instance.new(\"ScreenGui\")\r\nscreenGui.Parent = CoreGui -- 使用 CoreGui 确保 UI 始终位于最顶层\r\nscreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling -- 确保 UI 不被其他 UI 覆盖\r\n\r\n-- 创建悬浮窗背景\r\nlocal window = Instance.new(\"Frame\")\r\nwindow.Size = UDim2.new(0, 300, 0, 250)\r\nwindow.Position = UDim2.new(0, 50, 0, 50)\r\nwindow.BackgroundColor3 = Color3.fromRGB(50, 50, 50)\r\nwindow.BackgroundTransparency = 1.0\r\nwindow.Parent = screenGui\r\nwindow.BorderSizePixel = 0\r\n\r\n-- 创建标题\r\nlocal titleLabel = Instance.new(\"TextLabel\")\r\ntitleLabel.Size = UDim2.new(1, 0, 0, 30)\r\ntitleLabel.Position = UDim2.new(0, 0, 0, 0)\r\ntitleLabel.Text = \"X-Ray Control\"\r\ntitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)\r\ntitleLabel.TextSize = 18\r\ntitleLabel.BackgroundTransparency = 1\r\ntitleLabel.Parent = window\r\n\r\n-- 创建启用 X-Ray 按钮\r\nlocal enableButton = Instance.new(\"TextButton\")\r\nenableButton.Size = UDim2.new(0, 280, 0, 40)\r\nenableButton.Position = UDim2.new(0, 10, 0, 40)\r\nenableButton.Text = \"Enable X-Ray\"\r\nenableButton.Parent = window\r\nenableButton.BackgroundColor3 = Color3.fromRGB(0, 128, 255)\r\n\r\n-- 创建禁用 X-Ray 按钮\r\nlocal disableButton = Instance.new(\"TextButton\")\r\ndisableButton.Size = UDim2.new(0, 280, 0, 40)\r\ndisableButton.Position = UDim2.new(0, 10, 0, 90)\r\ndisableButton.Text = \"Disable X-Ray\"\r\ndisableButton.Parent = window\r\ndisableButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)\r\n\r\n-- 创建透明度调节滑动条背景\r\nlocal sliderBackground = Instance.new(\"Frame\")\r\nsliderBackground.Size = UDim2.new(0, 280, 0, 20)\r\nsliderBackground.Position = UDim2.new(0, 10, 0, 140)\r\nsliderBackground.BackgroundColor3 = Color3.fromRGB(100, 100, 100)\r\nsliderBackground.Parent = window\r\n\r\n-- 创建透明度滑动条\r\nlocal opacitySlider = Instance.new(\"Frame\")\r\nopacitySlider.Size = UDim2.new(0, 0, 1, 0) -- 初始长度为 0\r\nopacitySlider.Position = UDim2.new(0, 0, 0, 0)\r\nopacitySlider.BackgroundColor3 = Color3.fromRGB(0, 255, 255)\r\nopacitySlider.Parent = sliderBackground\r\n\r\n-- 创建一个透明度的数值标签\r\nlocal opacityLabel = Instance.new(\"TextLabel\")\r\nopacityLabel.Size = UDim2.new(0, 100, 0, 30)\r\nopacityLabel.Position = UDim2.new(1, -110, 0, 140)\r\nopacityLabel.Text = \"Opacity: 0.50\"\r\nopacityLabel.TextColor3 = Color3.fromRGB(255, 255, 255)\r\nopacityLabel.TextSize = 14\r\nopacityLabel.BackgroundTransparency = 1\r\nopacityLabel.Parent = window\r\n\r\n-- X-Ray 状态和透明度\r\nlocal xrayEnabled = false\r\nlocal transparency = 0.5\r\n\r\n-- X-Ray 控制函数\r\nlocal function xray()\r\n for _, v in pairs(workspace:GetDescendants()) do\r\n if v:IsA(\"BasePart\") and not v.Parent:FindFirstChildWhichIsA(\"Humanoid\") and not v.Parent.Parent:FindFirstChildWhichIsA(\"Humanoid\") then\r\n v.LocalTransparencyModifier = xrayEnabled and transparency or 0\r\n end\r\n end\r\nend\r\n\r\n-- 启用 X-Ray 按钮点击事件\r\nenableButton.MouseButton1Click:Connect(function()\r\n xrayEnabled = true\r\n xray() -- 调用 X-Ray 函数\r\n enableButton.Text = \"X-Ray Enabled\"\r\n disableButton.Text = \"Disable X-Ray\"\r\nend)\r\n\r\n-- 禁用 X-Ray 按钮点击事件\r\ndisableButton.MouseButton1Click:Connect(function()\r\n xrayEnabled = false\r\n xray() -- 调用 X-Ray 函数\r\n enableButton.Text = \"Enable X-Ray\"\r\n disableButton.Text = \"X-Ray Disabled\"\r\nend)\r\n\r\n-- 处理透明度调节滑动条\r\nlocal dragging = false\r\nsliderBackground.InputBegan:Connect(function(input)\r\n if input.UserInputType == Enum.UserInputType.MouseButton1 then\r\n dragging = true\r\n end\r\nend)\r\n\r\nsliderBackground.InputEnded:Connect(function(input)\r\n if input.UserInputType == Enum.UserInputType.MouseButton1 then\r\n dragging = false\r\n end\r\nend)\r\n\r\nsliderBackground.InputChanged:Connect(function(input)\r\n if dragging then\r\n local mouseX = input.Position.X\r\n local sliderPosX = math.clamp(mouseX - sliderBackground.AbsolutePosition.X, 0, sliderBackground.AbsoluteSize.X)\r\n opacitySlider.Size = UDim2.new(0, sliderPosX, 1, 0)\r\n\r\n -- 更新透明度值\r\n transparency = sliderPosX / sliderBackground.AbsoluteSize.X\r\n opacityLabel.Text = string.format(\"Opacity: %.2f\", transparency)\r\n xray() -- 调用 X-Ray 函数,实时更新透明度\r\n end\r\nend)"