--!strict local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Camera = workspace.CurrentCamera local BOMB_NAME: string = "BombMissile" local TOGGLE_KEY: Enum.KeyCode = Enum.KeyCode.X local SPEED: number = 300 local SPRINT_MULT: number = 2.5 local TURN_SENS: number = 0.003 local PITCH_CLAMP: number = math.rad(85) local INVERT_AD: boolean = true local BOMB_PITCH_OFFSET: number = math.rad(90) local tracked: BasePart? = nil local bodyVelocity: BodyVelocity? = nil local active: boolean = false local yaw: number = 0 local pitch: number = 0 local heartbeatConn: RBXScriptConnection? = nil local mouseMoveConn: RBXScriptConnection? = nil local keys: { [Enum.KeyCode]: boolean } = {} local function findBomb(): BasePart? local obj = workspace:FindFirstChild(BOMB_NAME, true) if not obj then return nil end if obj:IsA("BasePart") then return obj end if obj:IsA("Model") then return obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart") end return nil end local function ensureThrust(part: BasePart): BodyVelocity local existing = part:FindFirstChild("NoraPilot") :: BodyVelocity? if existing then return existing end local bv = Instance.new("BodyVelocity") bv.Name = "NoraPilot" bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bv.P = 10000 bv.Velocity = Vector3.zero bv.Parent = part return bv end local function cleanup() if bodyVelocity and bodyVelocity.Parent then bodyVelocity:Destroy() end bodyVelocity = nil tracked = nil active = false keys = {} if heartbeatConn then heartbeatConn:Disconnect() heartbeatConn = nil end if mouseMoveConn then mouseMoveConn:Disconnect() mouseMoveConn = nil end Camera.CameraType = Enum.CameraType.Custom if LocalPlayer.Character then local head = LocalPlayer.Character:FindFirstChild("Head") if head and head:IsA("BasePart") then Camera.CameraSubject = LocalPlayer.Character:FindFirstChildOfClass("Humanoid") or head end end end local function start() tracked = findBomb() if not tracked then print("бомбы нет") return end bodyVelocity = ensureThrust(tracked) active = true keys = {} local cf = tracked.CFrame yaw = math.atan2(-cf.LookVector.X, -cf.LookVector.Z) pitch = math.asin(cf.LookVector.Y) Camera.CameraType = Enum.CameraType.Scriptable print("пилот на " .. tracked.Name) heartbeatConn = RunService.Heartbeat:Connect(function(dt: number) if not active then return end if not tracked or not tracked.Parent then cleanup() return end if not bodyVelocity or not bodyVelocity.Parent then bodyVelocity = ensureThrust(tracked) end local rot = CFrame.fromEulerAnglesYXZ(pitch, yaw, 0) local forward = -rot.LookVector local right = rot.RightVector local up = Vector3.yAxis local adSign: number = if INVERT_AD then -1 else 1 local move = Vector3.zero if keys[Enum.KeyCode.W] then move += forward end if keys[Enum.KeyCode.S] then move -= forward end if keys[Enum.KeyCode.D] then move += right * adSign end if keys[Enum.KeyCode.A] then move -= right * adSign end if keys[Enum.KeyCode.Space] then move += up end if keys[Enum.KeyCode.LeftControl] then move -= up end local spd = SPEED if keys[Enum.KeyCode.LeftShift] then spd *= SPRINT_MULT end if move.Magnitude > 0 then move = move.Unit * spd end bodyVelocity.Velocity = move local bombRot = CFrame.fromEulerAnglesYXZ(pitch + BOMB_PITCH_OFFSET, yaw, 0) tracked.CFrame = CFrame.new(tracked.Position) * bombRot Camera.CFrame = CFrame.new(tracked.Position - forward * 12 + up * 4, tracked.Position + forward * 10) end) mouseMoveConn = UserInputService.InputChanged:Connect(function(input: InputObject) if not active then return end if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end if not UserInputService.MouseBehavior then return end yaw -= input.Delta.X * TURN_SENS pitch -= input.Delta.Y * TURN_SENS pitch = math.clamp(pitch, -PITCH_CLAMP, PITCH_CLAMP) end) UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter UserInputService.MouseIconEnabled = false end UserInputService.InputBegan:Connect(function(input: InputObject, gpe: boolean) if gpe then return end if input.KeyCode == TOGGLE_KEY then if active then UserInputService.MouseBehavior = Enum.MouseBehavior.Default UserInputService.MouseIconEnabled = true cleanup() print("вышел") else start() end return end if active then keys[input.KeyCode] = true end end) UserInputService.InputEnded:Connect(function(input: InputObject) keys[input.KeyCode] = false end)