local Player = game.Players.LocalPlayer local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Camera = workspace.CurrentCamera -- 1. 建立 UI local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "AutoGhost_Final_AnimFix" ScreenGui.ResetOnSpawn = false ScreenGui.Parent = Player:WaitForChild("PlayerGui") -- 主切換按鈕 local ToggleBtn = Instance.new("TextButton") ToggleBtn.Size = UDim2.new(0, 80, 0, 80) ToggleBtn.Position = UDim2.new(0, 30, 0.5, -120) ToggleBtn.BackgroundColor3 = Color3.fromRGB(0, 120, 215) ToggleBtn.Text = "OFF" ToggleBtn.TextColor3 = Color3.new(1, 1, 1) ToggleBtn.Font = Enum.Font.GothamBold ToggleBtn.TextSize = 20 ToggleBtn.Parent = ScreenGui Instance.new("UICorner", ToggleBtn).CornerRadius = UDim.new(1, 0) -- 時間輸入框 local TimeInput = Instance.new("TextBox") TimeInput.Size = UDim2.new(0, 80, 0, 30) TimeInput.Position = UDim2.new(0, 30, 0.5, -30) TimeInput.BackgroundColor3 = Color3.fromRGB(40, 40, 40) TimeInput.Text = "5" TimeInput.PlaceholderText = "秒數" TimeInput.TextColor3 = Color3.new(1, 1, 1) TimeInput.Font = Enum.Font.Gotham TimeInput.Parent = ScreenGui Instance.new("UICorner", TimeInput) -- 自動按鈕 local AutoToggle = Instance.new("TextButton") AutoToggle.Size = UDim2.new(0, 80, 0, 40) AutoToggle.Position = UDim2.new(0, 30, 0.5, 10) AutoToggle.BackgroundColor3 = Color3.fromRGB(150, 0, 0) AutoToggle.Text = "AUTO OFF" AutoToggle.TextColor3 = Color3.new(1, 1, 1) AutoToggle.Font = Enum.Font.GothamBold AutoToggle.Parent = ScreenGui Instance.new("UICorner", AutoToggle) ---------------- 核心變數 ---------------- local isModeOn = false local autoActive = false local RealChar = nil local FakeChar = nil local Connections = {} local AnimTracks = {} local function GetAnimID(char, name, subName) local animScript = char:FindFirstChild("Animate") if animScript then local value = animScript:FindFirstChild(name) if value then local anim = value:FindFirstChild(subName) or value:FindFirstChildOfClass("Animation") if anim then return anim.AnimationId end end end return nil end local function StopAllAnims() for _, track in pairs(AnimTracks) do if track then track:Stop(0.1) end end end local function DisableMode() if not isModeOn then return end isModeOn = false ToggleBtn.Text = "OFF" ToggleBtn.BackgroundColor3 = Color3.fromRGB(0, 120, 215) for _, conn in pairs(Connections) do conn:Disconnect() end Connections = {} StopAllAnims() AnimTracks = {} local targetCF = FakeChar and FakeChar:FindFirstChild("HumanoidRootPart") and FakeChar.HumanoidRootPart.CFrame if FakeChar then FakeChar:Destroy() FakeChar = nil end if RealChar and RealChar:FindFirstChild("HumanoidRootPart") then RealChar.HumanoidRootPart.Anchored = false if targetCF then RealChar.HumanoidRootPart.CFrame = targetCF end Player.Character = RealChar Camera.CameraSubject = RealChar:FindFirstChild("Humanoid") end end local function EnableMode() RealChar = Player.Character if not RealChar or not RealChar:FindFirstChild("HumanoidRootPart") then return end isModeOn = true ToggleBtn.Text = "ON" ToggleBtn.BackgroundColor3 = Color3.fromRGB(0, 200, 255) RealChar.HumanoidRootPart.Anchored = true RealChar.Archivable = true FakeChar = RealChar:Clone() FakeChar.Name = "LD_Ghost_Clone" FakeChar.Parent = workspace for _, v in pairs(FakeChar:GetDescendants()) do if v:IsA("LocalScript") or v:IsA("Script") then v:Destroy() end end for _, part in pairs(FakeChar:GetDescendants()) do if part:IsA("BasePart") then part.Anchored = false part.CanCollide = (part.Name == "HumanoidRootPart") if part.Name == "HumanoidRootPart" then part.Transparency = 1 for _, c in pairs(part:GetChildren()) do if c:IsA("Decal") or c:IsA("Texture") then c:Destroy() end end end end end local fakeHum = FakeChar:FindFirstChild("Humanoid") local fakeRoot = FakeChar:FindFirstChild("HumanoidRootPart") if fakeHum then fakeHum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None local function Load(id) if not id then return nil end local a = Instance.new("Animation") a.AnimationId = id return fakeHum:LoadAnimation(a) end AnimTracks.Run = Load(GetAnimID(RealChar, "run", "RunAnim") or GetAnimID(RealChar, "walk", "WalkAnim") or "rbxassetid://180426354") AnimTracks.Idle = Load(GetAnimID(RealChar, "idle", "Animation1") or "rbxassetid://180435571") AnimTracks.Jump = Load(GetAnimID(RealChar, "jump", "JumpAnim") or "rbxassetid://125750702") AnimTracks.Climb = Load(GetAnimID(RealChar, "climb", "ClimbAnim") or "rbxassetid://180436334") if AnimTracks.Idle then AnimTracks.Idle:Play() end end Camera.CameraSubject = fakeHum -- 控制邏輯 (這部分之前被省略了,現在補回) table.insert(Connections, UserInputService.JumpRequest:Connect(function() if isModeOn and fakeHum then fakeHum.Jump = true end end)) table.insert(Connections, RunService.RenderStepped:Connect(function() if not isModeOn or not FakeChar or not fakeHum or not fakeRoot then return end -- 移動計算 local moveDir = Vector3.new(0,0,0) local camCF = Camera.CFrame if UserInputService:IsKeyDown(Enum.KeyCode.W) then moveDir = moveDir + camCF.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.S) then moveDir = moveDir - camCF.LookVector end if UserInputService:IsKeyDown(Enum.KeyCode.A) then moveDir = moveDir - camCF.RightVector end if UserInputService:IsKeyDown(Enum.KeyCode.D) then moveDir = moveDir + camCF.RightVector end local finalDir = Vector3.new(moveDir.X, 0, moveDir.Z) fakeHum:Move(finalDir.Magnitude > 0 and finalDir.Unit or Vector3.new(0,0,0), false) -- 動態動畫切換 local velocity = fakeRoot.Velocity local speed = Vector3.new(velocity.X, 0, velocity.Z).Magnitude local isClimbing = fakeHum:GetState() == Enum.HumanoidStateType.Climbing if isClimbing then if AnimTracks.Climb and not AnimTracks.Climb.IsPlaying then StopAllAnims() AnimTracks.Climb:Play() end elseif velocity.Y > 5 then if AnimTracks.Jump and not AnimTracks.Jump.IsPlaying then StopAllAnims() AnimTracks.Jump:Play() end elseif speed > 0.5 then if AnimTracks.Run and not AnimTracks.Run.IsPlaying then StopAllAnims() AnimTracks.Run:Play() end else if AnimTracks.Idle and not AnimTracks.Idle.IsPlaying then StopAllAnims() AnimTracks.Idle:Play() end end end)) end ---------------- 自動循環邏輯 ---------------- local function StartAutoLoop() while autoActive do local waitSeconds = tonumber(TimeInput.Text) or 5 -- 開啟 if not isModeOn then EnableMode() end -- 等待設定的時間 local elapsed = 0 while elapsed < waitSeconds and autoActive do task.wait(0.1) elapsed = elapsed + 0.1 end -- 關閉並傳送 if autoActive then DisableMode() task.wait(1) -- 固定關閉 1 秒來重置本體 end end end AutoToggle.MouseButton1Click:Connect(function() autoActive = not autoActive if autoActive then AutoToggle.Text = "AUTO ON" AutoToggle.BackgroundColor3 = Color3.fromRGB(0, 180, 0) task.spawn(StartAutoLoop) else AutoToggle.Text = "AUTO OFF" AutoToggle.BackgroundColor3 = Color3.fromRGB(150, 0, 0) DisableMode() end end) ToggleBtn.MouseButton1Click:Connect(function() if isModeOn then DisableMode() else EnableMode() end end)