local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local PlayerModule = require(player.PlayerScripts:WaitForChild("PlayerModule")) local Controls = PlayerModule:GetControls() -- ================= НАСТРОЙКИ ================= local KEY = Enum.KeyCode.Z local PREVIEW_FPS = 24 local PREVIEW_STEP = 7.5 local TURN_SMOOTH = 0.35 local START_EXEC_AFTER = 12 local MAX_FRAMES_BUFFER = 30 local WALK_SPEED = 900 local ARRIVE_DIST = 3 local CAM_LERP = 0.15 local CAM_OFFSET = Vector3.new(0,4,0) -- ================= СОСТОЯНИЕ ================= local char local humanoid local hrp local active = false local executing = false local frames = {} local trails = {} local execIndex = 1 local frameTimer = 0 local currentDir = Vector3.zero local lastPreviewCF -- 🎥 camera target local camPart = Instance.new("Part") camPart.Size = Vector3.one camPart.Transparency = 1 camPart.Anchored = true camPart.CanCollide = false camPart.Parent = workspace -- ================= UTILS ================= local function clearTrails() for _,t in ipairs(trails) do if t.Parent then t:Destroy() end end trails = {} end local function resetState() active = false executing = false clearTrails() frames = {} execIndex = 1 if humanoid then humanoid.WalkSpeed = 16 humanoid.JumpPower = 50 end Controls:Enable() camera.CameraSubject = humanoid end -- ================= CHARACTER SETUP ================= local function setupCharacter(c) char = c humanoid = c:WaitForChild("Humanoid") hrp = c:WaitForChild("HumanoidRootPart") camera.CameraSubject = humanoid humanoid.Died:Connect(function() resetState() end) end if player.Character then setupCharacter(player.Character) end player.CharacterAdded:Connect(setupCharacter) -- ================= VISUAL ================= local function createTrail(cf) local p = Instance.new("Part") p.Size = Vector3.new(2,5,1) p.Anchored = true p.CanCollide = false p.Material = Enum.Material.Neon p.Color = Color3.fromRGB(170,70,255) p.CFrame = cf p.Parent = workspace table.insert(trails, p) end -- ================= START ================= local function start() if not humanoid or not hrp then return end active = true executing = false clearTrails() frames = {} execIndex = 1 frameTimer = 0 currentDir = hrp.CFrame.LookVector lastPreviewCF = hrp.CFrame humanoid.WalkSpeed = 0 humanoid.JumpPower = 0 camera.CameraSubject = camPart camPart.Position = hrp.Position end -- ================= STOP ================= local function stopAll() resetState() end -- ================= INPUT ================= UserInputService.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == KEY then start() end end) UserInputService.InputEnded:Connect(function(input, gp) if gp then return end if input.KeyCode == KEY then stopAll() end end) -- ================= UPDATE ================= RunService.Heartbeat:Connect(function(dt) if not active or not humanoid or not hrp then return end frameTimer += dt if frameTimer < 1 / PREVIEW_FPS then return end frameTimer -= 1 / PREVIEW_FPS -- INPUT DIR local look = camera.CFrame.LookVector local right = camera.CFrame.RightVector local inputDir = Vector3.zero if UserInputService:IsKeyDown(Enum.KeyCode.W) then inputDir += Vector3.new(look.X,0,look.Z) end if UserInputService:IsKeyDown(Enum.KeyCode.S) then inputDir -= Vector3.new(look.X,0,look.Z) end if UserInputService:IsKeyDown(Enum.KeyCode.A) then inputDir -= Vector3.new(right.X,0,right.Z) end if UserInputService:IsKeyDown(Enum.KeyCode.D) then inputDir += Vector3.new(right.X,0,right.Z) end if inputDir.Magnitude > 0 then currentDir = currentDir:Lerp(inputDir.Unit, TURN_SMOOTH) local lastCF = frames[#frames] or hrp.CFrame local nextPos = lastCF.Position + currentDir * PREVIEW_STEP local cf = CFrame.new(nextPos, nextPos + currentDir) table.insert(frames, cf) createTrail(cf) lastPreviewCF = cf if #frames > MAX_FRAMES_BUFFER then table.remove(frames, 1) local t = table.remove(trails, 1) if t then t:Destroy() end if execIndex > 1 then execIndex -= 1 end end end -- CAMERA FOLLOW if lastPreviewCF then camPart.Position = camPart.Position:Lerp( lastPreviewCF.Position + CAM_OFFSET, CAM_LERP ) end -- START EXECUTION if not executing and #frames >= START_EXEC_AFTER then executing = true Controls:Disable() humanoid.WalkSpeed = WALK_SPEED end -- MOVE if executing then local target = frames[execIndex] if not target then return end if (target.Position - hrp.Position).Magnitude <= ARRIVE_DIST then execIndex += 1 else humanoid:MoveTo(target.Position) end end end)