Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --====================================
- -- SIMPLE ADMIN FLY WITH SPEED GUI
- --====================================
- local Players = game:GetService("Players")
- local UIS = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- local root = character:WaitForChild("HumanoidRootPart")
- -- SETTINGS
- local flying = false
- local flySpeed = 50
- local SPEED_STEP = 25 -- for ' and /
- local GUI_SCALE_SPEED = 500 -- bar visual scale only
- -- BODY MOVERS
- local bv, bg
- --====================================
- -- FLY FUNCTIONS
- --====================================
- local function startFly()
- flying = true
- bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- bv.Velocity = Vector3.zero
- bv.Parent = root
- bg = Instance.new("BodyGyro")
- bg.MaxTorque = Vector3.new(1e9, 1e9, 1e9)
- bg.P = 9000
- bg.Parent = root
- humanoid.PlatformStand = true
- end
- local function stopFly()
- flying = false
- if bv then bv:Destroy() end
- if bg then bg:Destroy() end
- humanoid.PlatformStand = false
- end
- --====================================
- -- FLY MOVEMENT LOOP
- --====================================
- RunService.RenderStepped:Connect(function()
- if not flying then return end
- local cam = workspace.CurrentCamera
- local move = Vector3.zero
- if UIS:IsKeyDown(Enum.KeyCode.W) then move += cam.CFrame.LookVector end
- if UIS:IsKeyDown(Enum.KeyCode.S) then move -= cam.CFrame.LookVector end
- if UIS:IsKeyDown(Enum.KeyCode.A) then move -= cam.CFrame.RightVector end
- if UIS:IsKeyDown(Enum.KeyCode.D) then move += cam.CFrame.RightVector end
- if UIS:IsKeyDown(Enum.KeyCode.Space) then move += Vector3.yAxis end
- if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then move -= Vector3.yAxis end
- if move.Magnitude > 0 then
- move = move.Unit * flySpeed
- end
- bv.Velocity = bv.Velocity:Lerp(move, 0.2)
- bg.CFrame = CFrame.new(root.Position, root.Position + cam.CFrame.LookVector)
- end)
- --====================================
- -- INPUT
- --====================================
- UIS.InputBegan:Connect(function(input, gpe)
- if gpe then return end
- if input.KeyCode == Enum.KeyCode.F then
- if flying then
- stopFly()
- else
- startFly()
- end
- elseif input.KeyCode == Enum.KeyCode.Quote then
- flySpeed += SPEED_STEP
- updateGui()
- elseif input.KeyCode == Enum.KeyCode.Slash then
- flySpeed = math.max(1, flySpeed - SPEED_STEP)
- updateGui()
- end
- end)
- --====================================
- -- SPEED GUI
- --====================================
- local gui = Instance.new("ScreenGui")
- gui.Name = "FlySpeedGui"
- gui.ResetOnSpawn = false
- gui.Parent = player:WaitForChild("PlayerGui")
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 60, 0, 300)
- frame.Position = UDim2.new(1, -80, 0.5, -150)
- frame.BackgroundColor3 = Color3.fromRGB(25,25,25)
- frame.BorderSizePixel = 0
- Instance.new("UICorner", frame).CornerRadius = UDim.new(0, 12)
- local barBg = Instance.new("Frame", frame)
- barBg.Size = UDim2.new(0, 20, 1, -50)
- barBg.Position = UDim2.new(0.5, -10, 0, 10)
- barBg.BackgroundColor3 = Color3.fromRGB(50,50,50)
- barBg.BorderSizePixel = 0
- Instance.new("UICorner", barBg).CornerRadius = UDim.new(1,0)
- local bar = Instance.new("Frame", barBg)
- bar.AnchorPoint = Vector2.new(0,1)
- bar.Position = UDim2.new(0,0,1,0)
- bar.Size = UDim2.new(1,0,0.2,0)
- bar.BackgroundColor3 = Color3.fromRGB(0,170,255)
- bar.BorderSizePixel = 0
- Instance.new("UICorner", bar).CornerRadius = UDim.new(1,0)
- local speedBox = Instance.new("TextBox", frame)
- speedBox.Size = UDim2.new(1,-10,0,30)
- speedBox.Position = UDim2.new(0,5,1,-35)
- speedBox.BackgroundColor3 = Color3.fromRGB(35,35,35)
- speedBox.TextColor3 = Color3.fromRGB(0,170,255)
- speedBox.TextScaled = true
- speedBox.ClearTextOnFocus = false
- speedBox.BorderSizePixel = 0
- speedBox.Text = tostring(flySpeed)
- Instance.new("UICorner", speedBox).CornerRadius = UDim.new(0,8)
- --====================================
- -- GUI LOGIC
- --====================================
- function updateGui()
- local percent = math.clamp(flySpeed / GUI_SCALE_SPEED, 0, 1)
- bar.Size = UDim2.new(1,0,percent,0)
- speedBox.Text = tostring(math.floor(flySpeed))
- end
- updateGui()
- local dragging = false
- barBg.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- end
- end)
- UIS.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- UIS.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local y = input.Position.Y
- local top = barBg.AbsolutePosition.Y
- local height = barBg.AbsoluteSize.Y
- local percent = math.clamp(1 - ((y - top) / height), 0, 1)
- flySpeed = math.max(1, percent * GUI_SCALE_SPEED)
- updateGui()
- end
- end)
- speedBox.FocusLost:Connect(function()
- local num = tonumber(speedBox.Text)
- if num and num > 0 then
- flySpeed = num
- end
- updateGui()
- end)
- --====================================
- -- CHARACTER RESPAWN FIX
- --====================================
- player.CharacterAdded:Connect(function(char)
- character = char
- humanoid = char:WaitForChild("Humanoid")
- root = char:WaitForChild("HumanoidRootPart")
- stopFly()
- end)
Advertisement
Add Comment
Please, Sign In to add comment