Last active
June 23, 2025 16:31
-
-
Save depthso/40e6fc075740dea55320b472a3a258c7 to your computer and use it in GitHub Desktop.
Minecraft styled flight without using PlatformStand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --[[ | |
| @author depso (depthso) | |
| @description Minecraft styled flight without using PlatformStand | |
| -- Keybinds | |
| W, S - Forward, Backwards | |
| A, D - Left, Right | |
| Shift, Q - Down | |
| Space, E - Up | |
| Ctrl - Sprint | |
| F - Toggle flight (Changable in UI) | |
| ]] | |
| --// Services | |
| local Players = game:GetService("Players") | |
| local UserInputService = game:GetService("UserInputService") | |
| local RunService = game:GetService("RunService") | |
| local InsertService = game:GetService("InsertService") | |
| --// ReGui (UI Library) | |
| local ReGui = loadstring(game:HttpGet('https://raw.githubusercontent.com/depthso/Dear-ReGui/refs/heads/main/ReGui.lua'))() | |
| local PrefabsId = "rbxassetid://" .. ReGui.PrefabsId | |
| ReGui:Init({ | |
| Prefabs = InsertService:LoadLocalAsset(PrefabsId) | |
| }) | |
| --// LocalPlayer | |
| local Camera = workspace.CurrentCamera | |
| local LocalPlayer = Players.LocalPlayer | |
| local Character, Root | |
| local FlyCFrame | |
| local function CharacterAdded(NewCharacter) | |
| Character = NewCharacter or LocalPlayer.CharacterAdded:Wait() | |
| Root = Character:WaitForChild("HumanoidRootPart") | |
| end | |
| local function RefreshPivot() | |
| FlyCFrame = Character:GetPivot() | |
| end | |
| CharacterAdded(LocalPlayer.Character) | |
| RefreshPivot() | |
| ----// Create UI Window | |
| local Window = ReGui:Window({ | |
| Title = "Flight | Depso", | |
| Size = UDim2.fromOffset(300, 150) | |
| }) | |
| ----// Toggles | |
| local EnabledCheckbox = Window:Checkbox({Label = "Enabled", Value = false}) | |
| Window:Keybind({Label = "Toggle keybind", Value = Enum.KeyCode.F, Callback=function() | |
| --// Toggle the enabled checkbox | |
| local Enabled = not EnabledCheckbox.Value | |
| EnabledCheckbox:SetValue(Enabled) | |
| --// Refresh the base pivot | |
| if not Enabled then return end | |
| RefreshPivot() | |
| end}) | |
| ----// Speeds | |
| Window:Separator({Text = "Speeds"}) | |
| local FlightSpeed = Window:SliderInt({Label = "Flight speed", Minimum = 1, Maximum = 20}) | |
| local SprintSpeed = Window:SliderInt({Label = "Sprint multiply", Minimum = 4, Maximum = 20}) | |
| --// Flight tick | |
| RunService.Stepped:Connect(function() | |
| local Enabled = EnabledCheckbox.Value | |
| local Speed = FlightSpeed.Value | |
| local SprintMuli = SprintSpeed.Value | |
| --// Check if the flight is enabled | |
| if not Enabled then return end | |
| --// Base pivot | |
| local CX, CY, CZ = Camera.CFrame.Rotation:ToOrientation() | |
| local Rotation = CFrame.Angles(0, CY, 0) | |
| local Pivot = CFrame.new(FlyCFrame.Position) * Rotation | |
| --// Reset the Root's velocity | |
| local V = Root.Velocity | |
| Root.Velocity = Vector3.new(0, V.Y < 0 and math.abs(V.Y) or 0.5,0) | |
| --// Sprint | |
| local Sprint = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) | |
| Speed *= Sprint and SprintMuli or 1 | |
| --// Horizontal | |
| local Left = UserInputService:IsKeyDown(Enum.KeyCode.A) | |
| local Right = UserInputService:IsKeyDown(Enum.KeyCode.D) | |
| local Horizontal = (Left and -Speed) or (Right and Speed) or 0 | |
| --// Vertical | |
| local Shift = UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) | |
| local Space = UserInputService:IsKeyDown(Enum.KeyCode.Space) | |
| Shift = Shift or UserInputService:IsKeyDown(Enum.KeyCode.Q) | |
| Space = Space or UserInputService:IsKeyDown(Enum.KeyCode.E) | |
| local Vertical = (Shift and -Speed) or (Space and Speed) or 0 | |
| --// Forward | |
| local Forwards = UserInputService:IsKeyDown(Enum.KeyCode.W) | |
| local Backwards = UserInputService:IsKeyDown(Enum.KeyCode.S) | |
| local Forward = (Forwards and -Speed) or (Backwards and Speed) or 0 | |
| --// Calulate final Pivot | |
| FlyCFrame = Pivot * CFrame.new( | |
| Horizontal, | |
| Vertical, | |
| Forward | |
| ) | |
| --// Pivot Character | |
| Character:PivotTo(FlyCFrame) | |
| end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment