-- #region Rayfield local Rayfield = loadstring(game:HttpGet('https://sirius.menu/rayfield'))() local Window = Rayfield:CreateWindow({ Name = "Fly Script | clem.la", Icon = "plane", LoadingTitle = "Coming up!", LoadingSubtitle = "by clem.la", ShowText = "Rayfield", Theme = "Default", -- Check https://docs.sirius.menu/rayfield/configuration/themes ToggleUIKeybind = Enum.KeyCode.RightControl, DisableRayfieldPrompts = true, DisableBuildWarnings = false, ConfigurationSaving = { Enabled = true, FolderName = "clemdotla", FileName = "Fly" }, }) local Main = Window:CreateTab("Main", "badge") -- #endregion Rayfield -- #region Defines local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local root = character:WaitForChild("HumanoidRootPart") local flyToggle = false local flySpeed = 100 local moveDir = Vector3.new(0, 0, 0) local att local velocity local orientation -- #endregion Defines -- #region Cleanup if getgenv().clemFly then if getgenv().clemFly.Events then for i,v in getgenv().clemFly.Events do print("Disconnecting: ".. i) pcall(function() v:Disconnect() end) end end if getgenv().clemFly.Parts then for i,v in getgenv().clemFly.Parts do pcall(function() v:Destroy() end) end end end getgenv().clemFly = {Events = {}, Parts = {}} -- #endregion Cleanup -- #region Parts function CleanParts() if getgenv().clemFly.Parts then for i,v in getgenv().clemFly.Parts do print("Destroying: ".. i) pcall(function() v:Destroy() end) end end getgenv().clemFly.Parts = {} end function MakeParts() character = player.Character or player.CharacterAdded:Wait() root = character:WaitForChild("HumanoidRootPart") att = Instance.new("Attachment", root) att.Name = "FlyAttachment" getgenv().clemFly.Parts.att = att velocity = Instance.new("LinearVelocity") velocity.Name = "FlyVelocity" velocity.Attachment0 = att velocity.MaxForce = math.huge velocity.RelativeTo = Enum.ActuatorRelativeTo.World velocity.Enabled = false velocity.Parent = root getgenv().clemFly.Parts.velocity = velocity orientation = Instance.new("AlignOrientation") orientation.Name = "FlyOrientation" orientation.Attachment0 = att orientation.Mode = Enum.OrientationAlignmentMode.OneAttachment orientation.Responsiveness = 200 orientation.Enabled = false orientation.Parent = root getgenv().clemFly.Parts.orientation = orientation end -- #endregion Parts -- #region UI local Toggle = Main:CreateToggle({ Name = "Toggle fly", CurrentValue = false, Callback = function(Value) flyToggle = Value end, }) Main:CreateKeybind({ Name = "Toggle fly", CurrentKeybind = "Q", HoldToInteract = false, Flag = "FlyKeybind", Callback = function(Keybind) Toggle:Set(not flyToggle) end }) Main:CreateSlider({ Name = "Speed", Range = {100, 300}, Increment = 10, Suffix = "", CurrentValue = 100, Flag = "SpeedSlider", Callback = function(Value) flySpeed = Value end, }) -- #endregion UI -- #region Events MakeParts() getgenv().clemFly.Events.Respawn = player.CharacterAdded:Connect(function() CleanParts() MakeParts() Toggle:Set(false) end) local Keybinds = { W = Vector3.new(0, 0, -1), S = Vector3.new(0, 0, 1), A = Vector3.new(-1, 0, 0), D = Vector3.new(1, 0, 0), Space = Vector3.new(0, 1, 0), LeftControl = Vector3.new(0, -1, 0) } getgenv().clemFly.Events.InputBegan = UserInputService.InputBegan:Connect(function(input, gp) local dir = Keybinds[input.KeyCode.Name] if not gp and dir then moveDir += dir end end) getgenv().clemFly.Events.InputEnded = UserInputService.InputEnded:Connect(function(input, gp) local dir = Keybinds[input.KeyCode.Name] if not gp and dir then moveDir -= dir end end) -- Loop every frame getgenv().clemFly.Events.Loop = RunService.RenderStepped:Connect(function() if not flyToggle then velocity.Enabled = false orientation.Enabled = false return end velocity.Enabled = true orientation.Enabled = true local cam = workspace.CurrentCamera orientation.CFrame = cam.CFrame local dir = cam.CFrame:VectorToWorldSpace(moveDir) if dir.Magnitude > 0 then dir = dir.Unit end velocity.VectorVelocity = dir * flySpeed end) -- #endregion Events Rayfield:LoadConfiguration()