Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- this script was made by me (Sheepz).
- local player = game.Players.LocalPlayer
- local character = player.Character
- local humanoid = character and character:FindFirstChild("Humanoid")
- local flying = false
- local flySpeed = 50 -- you can adjust this value to change the flying speed.
- local function enableFlying()
- if humanoid then
- humanoid.PlatformStand = true
- humanoid.AutoRotate = false
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Flying, true)
- flying = true
- end
- end
- local function disableFlying()
- if humanoid then
- humanoid.PlatformStand = false
- humanoid.AutoRotate = true
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Flying, false)
- flying = false
- end
- end
- local function handleInput(input, gameProcessedEvent)
- if gameProcessedEvent then
- return
- end
- if flying and input.UserInputType == Enum.UserInputType.Keyboard then
- local moveVector = Vector3.new()
- if input.KeyCode == Enum.KeyCode.W then
- moveVector = moveVector + Vector3.new(0, 0, -1)
- end
- if input.KeyCode == Enum.KeyCode.S then
- moveVector = moveVector + Vector3.new(0, 0, 1)
- end
- if input.KeyCode == Enum.KeyCode.A then
- moveVector = moveVector + Vector3.new(-1, 0, 0)
- end
- if input.KeyCode == Enum.KeyCode.D then
- moveVector = moveVector + Vector3.new(1, 0, 0)
- end
- character:SetPrimaryPartCFrame(CFrame.new(character.PrimaryPart.Position + moveVector * flySpeed))
- end
- end
- game:GetService("UserInputService").InputBegan:Connect(handleInput)
- game:GetService("UserInputService").InputChanged:Connect(handleInput)
- local gui = Instance.new("ScreenGui")
- gui.Parent = player.PlayerGui
- gui.Name = "TPFlyingGUI"
- local enableButton = Instance.new("TextButton")
- enableButton.Parent = gui
- enableButton.Size = UDim2.new(0, 100, 0, 50)
- enableButton.Position = UDim2.new(0.25, 0, 0.4, 0)
- enableButton.Text = "Enable TPFlying"
- enableButton.FontSize = Enum.FontSize.Size24
- enableButton.TextColor3 = Color3.new(1, 1, 1)
- enableButton.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
- enableButton.BorderSizePixel = 0
- enableButton.MouseButton1Click:Connect(enableFlying)
- local disableButton = Instance.new("TextButton")
- disableButton.Parent = gui
- disableButton.Size = UDim2.new(0, 100, 0, 50)
- disableButton.Position = UDim2.new(0.65, 0, 0.4, 0)
- disableButton.Text = "Disable TPFlying"
- disableButton.FontSize = Enum.FontSize.Size24
- disableButton.TextColor3 = Color3.new(1, 1, 1)
- disableButton.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
- disableButton.BorderSizePixel = 0
- disableButton.MouseButton1Click:Connect(disableFlying)
Advertisement
Comments
-
- ik the ui is bad but it works
-
- also sorry for not uploading anything for months i've been busy with other things
-
- Hey sheepz can you send script fly but when text button is clicked then it activates?
-
- it does activate though
-
- If I add Image Button, will it work?
Add Comment
Please, Sign In to add comment
Advertisement