Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player, mouse, userInputService = game.Players.LocalPlayer, game.Players.LocalPlayerGetMouse(), gameGetService(UserInputService)
- local screenGui, frame = Instance.new(ScreenGui), Instance.new(Frame)
- screenGui.Parent, screenGui.Name = player.PlayerGui, NexUsFlyGui
- frame.Size, frame.Position = UDim2.new(0, 200, 0, 100), UDim2.new(0.5, -100, 0.5, -50)
- frame.BackgroundColor3, frame.BorderSizePixel = Color3.fromRGB(0, 0, 0), 0
- frame.Parent = screenGui
- -- Speed slider and label
- local slider = Instance.new(Slider)
- slider.Size, slider.Position = UDim2.new(0, 180, 0, 20), UDim2.new(0, 10, 0, 50)
- slider.MinValue, slider.MaxValue, slider.Value = 1, 1000, 100
- slider.Parent = frame
- local speedLabel = Instance.new(TextLabel)
- speedLabel.Size, speedLabel.Position = UDim2.new(0, 200, 0, 20), UDim2.new(0, 10, 0, 20)
- speedLabel.Text, speedLabel.TextColor3 = Fly Speed 100, Color3.fromRGB(255, 255, 255)
- speedLabel.BackgroundTransparency = 1
- speedLabel.Parent = frame
- -- Draggable GUI functionality
- local dragging, dragStart, startPos = false, nil, nil
- frame.InputBeganConnect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging, dragStart, startPos = true, input.Position, frame.Position
- end
- end)
- frame.InputChangedConnect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local delta = input.Position - dragStart
- frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- end)
- frame.InputEndedConnect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- -- Fly logic
- local flying, bodyVelocity, flySpeed = false, Instance.new(BodyVelocity), 100
- local function toggleFly()
- local char, rootPart = player.Character, player.Character and player.CharacterFindFirstChild(HumanoidRootPart)
- if not char or not rootPart then return end
- if flying then
- bodyVelocityDestroy()
- flying = false
- else
- flying = true
- bodyVelocity.MaxForce = Vector3.new(100000, 100000, 100000)
- bodyVelocity.Velocity = Vector3.new(0, 50, 0)
- bodyVelocity.Parent = rootPart
- gameGetService(RunService).HeartbeatConnect(function()
- if flying then
- bodyVelocity.Velocity = (mouse.Hit.p - rootPart.Position).unit flySpeed
- end
- end)
- end
- end
- -- Toggle flying on spacebar
- userInputService.InputBeganConnect(function(input)
- if input.KeyCode == Enum.KeyCode.Space then
- toggleFly()
- end
- end)
- -- Update speed on slider change
- slider.ChangedConnect(function()
- flySpeed = slider.Value
- speedLabel.Text = Fly Speed .. math.floor(flySpeed)
- end)
Add Comment
Please, Sign In to add comment