Advertisement
Guest User

Roblox - Fly script [FE]

a guest
Feb 12th, 2019
40,897
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 1 0
  1. (Local Script)
  2.  
  3. Player = game.Players.LocalPlayer
  4. Mouse = Player:GetMouse()
  5. game.Workspace:WaitForChild(Player.Name)
  6. ReplicatedStorage = game:GetService("ReplicatedStorage")
  7. RemoteEvent = ReplicatedStorage:WaitForChild("Flying")
  8. RemoteEvent2 = ReplicatedStorage:WaitForChild("FlyingOff")
  9. Debounce = 1
  10.  
  11. game:GetService("UserInputService").InputBegan:Connect(function(input)
  12.     if input.KeyCode == Enum.KeyCode.F and Debounce == 1 then -- if Player press F and Debounce = 1
  13.     Debounce = 2    -- Debounce = 2
  14.     RemoteEvent:FireServer() -- Fire remote
  15.     for i = 1, math.huge do -- Loop for Player's humanoid root part follows mouse
  16.         if Debounce == 2 then -- if debounce = 2 then follow mouse
  17.         wait()
  18.         Player.Character.HumanoidRootPart.CFrame = CFrame.new(Player.Character.HumanoidRootPart.Position,Mouse.Hit.p)
  19.         else -- else break the loop
  20.             break
  21.         end
  22.     end
  23.  end
  24. end)
  25.  
  26.  
  27.  
  28. game:GetService("UserInputService").InputEnded:Connect(function(input)
  29.     if input.KeyCode == Enum.KeyCode.F and Debounce == 2 then -- if Player release F and Debounce == 2
  30.         script.Disabled = true -- script disabled (Debounce = 1)
  31.        
  32.         RemoteEvent2:FireServer() -- fire second remote
  33.         wait(3) -- wait time
  34.         script.Disabled = false -- script enabled
  35.     end
  36. end)
  37.  
  38.  
  39.  
  40. (Remote event script)
  41.  
  42.  
  43. ReplicatedStorage = game:GetService("ReplicatedStorage")
  44. RemoteEvent = ReplicatedStorage:WaitForChild("Flying")
  45.  
  46. RemoteEvent2 = ReplicatedStorage:WaitForChild("FlyingOff")
  47.  
  48. RemoteEvent.OnServerEvent:Connect(function(Player)
  49.    
  50.     Vel = Instance.new("BodyVelocity", Player.Character.HumanoidRootPart) -- Create new velicoty inside humanoid root part
  51.     Vel.Name = "FlyVelocity"
  52.     Vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  53.     for i = 1, math.huge do -- loop for Velocity
  54.         if Player.Character.HumanoidRootPart:FindFirstChild("FlyVelocity") ~= nil then -- if velocity exists
  55.         Vel.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector*100
  56.         else -- else break the loop
  57.             break
  58.            
  59.         end
  60.         wait()
  61.     end
  62.    
  63. end)
  64.  
  65.  
  66. RemoteEvent2.OnServerEvent:Connect(function(Player)
  67.     Vel:Destroy() -- destroy velocity
  68.    
  69.    
  70. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement