How to give a player the ability to fly?
I made a script for flying but it doesn't work. If I loop the part that lifts up the player, the player falls down to the ground after lifting by 1/5 of a stud. If I put multiple together it will lift the player a higher. I don't understand why repetition of the line lifts up the player, but a loop won't lift them up. Can someone tell me what I am doing wrong to try and give the player flying abilities. One more problem is the player will always turn to a certain direction whenever I hold space to try and fly. I know it has something to do with how I'm trying to fly, but I don't know what since I don't usually work with CFrames.
Here's is the code
01 | local plr = game.Players.LocalPlayer |
02 | repeat wait() until plr.Character |
03 | local HRP = plr.Character.HumanoidRootPart |
04 | local uis = game:GetService( 'UserInputService' ) |
08 | if plr.Mode.Value = = 'Flying' then |
09 | while uis:IsKeyDown(Enum.KeyCode.Space) do |
11 | HRP.CFrame = CFrame.new(Vector 3. new(HRP.Position.X, HRP.Position.Y + 0.2 , HRP.Position.Z)) |