// Name: Roblox Smooth Fly Script // Description: Generates a smooth flight LocalScript for Roblox Studio and copies it to the clipboard. // Author: atimegamer1-spec // GitHub: atimegamer1-spec import "@johnlindquist/kit" const [toggleKeyInput, baseSpeedStr, sprintMultStr, accelStr] = await fields([ { label: "Toggle key (e.g., F)", placeholder: "F", value: "F", required: true }, { label: "Base speed (studs/sec)", placeholder: "50", value: "50", type: "number" }, { label: "Sprint multiplier (Shift)", placeholder: "2", value: "2", type: "number" }, { label: "Smoothing (higher = snappier)", placeholder: "8", value: "8", type: "number" }, ]) const keySanitize = (s: string) => { const t = (s || "F").trim() if (t.length === 1) { const ch = t.toUpperCase() // Letters or digits map directly in Enum.KeyCode if ((ch >= "A" && ch <= "Z") || (ch >= "0" && ch <= "9")) return ch } // Remove spaces and make PascalCase-ish for common names return t.replace(/\s+/g, "") } const keyName = keySanitize(toggleKeyInput || "F") const baseSpeed = Math.max(1, Number.isFinite(parseFloat(baseSpeedStr)) ? parseFloat(baseSpeedStr) : 50) const sprintMult = Math.max(1, Number.isFinite(parseFloat(sprintMultStr)) ? parseFloat(sprintMultStr) : 2) const accel = Math.max(0.1, Number.isFinite(parseFloat(accelStr)) ? parseFloat(accelStr) : 8) const lua = `--[[ Roblox Smooth Fly (LocalScript) - Place this LocalScript in StarterPlayer > StarterPlayerScripts - Toggle flight with [${keyName}] - Hold Shift to sprint (multiplies speed) - Move with WASD, ascend with [E], descend with [Q] - Intended for your own experiences and Studio testing. Notes: - Smooth motion uses frame-rate independent lerp with exponential smoothing. - PlatformStand is toggled while flying to avoid character states fighting physics. --]] local UIS = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local TOGGLE_KEY = Enum.KeyCode.${keyName} local BASE_SPEED = ${baseSpeed} local SPRINT_MULT = ${sprintMult} local ACCEL = ${accel} -- higher = snappier, lower = smoother/floatier local player = Players.LocalPlayer local character local humanoid local hrp local flying = false local moveX, moveZ = 0, 0 local moveY = 0 local vel = Vector3.zero local function bindCharacter(char) character = char humanoid = character:WaitForChild("Humanoid") hrp = character:WaitForChild("HumanoidRootPart") flying = false vel = Vector3.zero if humanoid then humanoid.PlatformStand = false end end if player.Character then bindCharacter(player.Character) end player.CharacterAdded:Connect(bindCharacter) local function getSpeed() local sprinting = UIS:IsKeyDown(Enum.KeyCode.LeftShift) or UIS:IsKeyDown(Enum.KeyCode.RightShift) return BASE_SPEED * (sprinting and SPRINT_MULT or 1) end UIS.InputBegan:Connect(function(input, gp) if gp then return end if input.KeyCode == TOGGLE_KEY then flying = not flying if humanoid then humanoid.PlatformStand = flying end if not flying then vel = Vector3.zero if hrp then hrp.AssemblyLinearVelocity = Vector3.zero hrp.AssemblyAngularVelocity = Vector3.zero end end elseif input.KeyCode == Enum.KeyCode.W then moveZ = -1 elseif input.KeyCode == Enum.KeyCode.S then moveZ = 1 elseif input.KeyCode == Enum.KeyCode.A then moveX = -1 elseif input.KeyCode == Enum.KeyCode.D then moveX = 1 elseif input.KeyCode == Enum.KeyCode.E then moveY = 1 elseif input.KeyCode == Enum.KeyCode.Q then moveY = -1 end end) UIS.InputEnded:Connect(function(input, gp) if gp then return end if input.KeyCode == Enum.KeyCode.W and moveZ == -1 then moveZ = 0 elseif input.KeyCode == Enum.KeyCode.S and moveZ == 1 then moveZ = 0 elseif input.KeyCode == Enum.KeyCode.A and moveX == -1 then moveX = 0 elseif input.KeyCode == Enum.KeyCode.D and moveX == 1 then moveX = 0 elseif input.KeyCode == Enum.KeyCode.E and moveY == 1 then moveY = 0 elseif input.KeyCode == Enum.KeyCode.Q and moveY == -1 then moveY = 0 end end) RunService.RenderStepped:Connect(function(dt) if not flying or not hrp then return end -- Build desired direction relative to camera local cam = workspace.CurrentCamera if not cam then return end local cf = cam.CFrame local forward = cf.LookVector local right = cf.RightVector local up = Vector3.yAxis local dir = (right * moveX) + (forward * (-moveZ)) + (up * moveY) if dir.Magnitude > 1 then dir = dir.Unit end local targetVel = dir * getSpeed() -- Exponential smoothing (frame-rate independent) local alpha = 1 - math.exp(-ACCEL * dt) vel = vel:Lerp(targetVel, alpha) hrp.AssemblyLinearVelocity = vel hrp.AssemblyAngularVelocity = Vector3.zero end) ` await copy(lua) await editor({ value: lua, hint: "Copied to clipboard. Save this as a LocalScript in StarterPlayerScripts.", }) await toast("Roblox Fly script copied", { autoClose: 2000 })