Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create ScreenGui
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "FlyGui"
- screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Create Frame
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(0.3, 0, 0.3, 0)
- frame.Position = UDim2.new(0.35, 0, 0.35, 0)
- frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- frame.BackgroundTransparency = 0.5
- frame.Active = true
- frame.Draggable = true
- frame.Parent = screenGui
- -- Create Enable Fly Button
- local enableFlyButton = Instance.new("TextButton")
- enableFlyButton.Size = UDim2.new(0.8, 0, 0.3, 0)
- enableFlyButton.Position = UDim2.new(0.1, 0, 0.1, 0)
- enableFlyButton.Text = "Enable Fly"
- enableFlyButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- enableFlyButton.TextScaled = true
- enableFlyButton.Parent = frame
- -- Create Disable Fly Button
- local disableFlyButton = Instance.new("TextButton")
- disableFlyButton.Size = UDim2.new(0.8, 0, 0.3, 0)
- disableFlyButton.Position = UDim2.new(0.1, 0, 0.5, 0)
- disableFlyButton.Text = "Disable Fly"
- disableFlyButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- disableFlyButton.TextScaled = true
- disableFlyButton.Parent = frame
- -- Variables for flying
- local flying = false
- local speed = 50
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- -- Function to start flying
- local function startFly()
- if flying then return end
- flying = true
- local bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.Velocity = Vector3.new(0, 0, 0)
- bodyVelocity.MaxForce = Vector3.new(4000, 4000, 4000)
- bodyVelocity.Parent = humanoidRootPart
- local bodyGyro = Instance.new("BodyGyro")
- bodyGyro.MaxTorque = Vector3.new(4000, 4000, 4000)
- bodyGyro.CFrame = humanoidRootPart.CFrame
- bodyGyro.Parent = humanoidRootPart
- spawn(function()
- while flying do
- local camera = game.Workspace.CurrentCamera
- local direction = camera.CFrame.lookVector
- bodyVelocity.Velocity = direction * speed
- bodyGyro.CFrame = camera.CFrame
- wait()
- end
- bodyVelocity:Destroy()
- bodyGyro:Destroy()
- end)
- end
- -- Function to stop flying
- local function stopFly()
- flying = false
- end
- -- Button functions
- enableFlyButton.MouseButton1Click:Connect(startFly)
- disableFlyButton.MouseButton1Click:Connect(stopFly)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement