Advertisement
terrame341

Untitled

May 22nd, 2022 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1.     Fly = true
  2.   local mouse=game.Players.LocalPlayer:GetMouse''
  3.   localplayer=game.Players.LocalPlayer
  4.   game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
  5.   local torso = game.Players.LocalPlayer.Character.HumanoidRootPart
  6.   local speed=0
  7.     local max_speed = _G.MaxSpeed
  8.   local keys={a=false,d=false,w=false,s=false}
  9.   local e1
  10.   local e2
  11.   local function start()
  12.    local pos = Instance.new("BodyPosition",torso)
  13.    local gyro = Instance.new("BodyGyro",torso)
  14.    pos.Name="EPIXPOS"
  15.    pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  16.    pos.position = torso.Position
  17.    gyro.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  18.    gyro.cframe = torso.CFrame
  19.    repeat
  20.     wait()
  21.     localplayer.Character.Humanoid.PlatformStand=true
  22.     local new=gyro.cframe - gyro.cframe.p + pos.position
  23.     if not keys.w and not keys.s and not keys.a and not keys.d then
  24.      speed=1
  25.     end
  26.     if keys.w then
  27.      new = new + workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  28.      speed=max_speed
  29.     end
  30.     if keys.d then
  31.      new = new * CFrame.new(speed,0,0)
  32.      speed=max_speed
  33.     end
  34.     if keys.a then
  35.      new = new * CFrame.new(-speed,0,0)
  36.      speed=max_speed
  37.     end
  38.     if keys.s then
  39.      new = new - workspace.CurrentCamera.CoordinateFrame.lookVector * speed
  40.      speed=max_speed
  41.     end
  42.     pos.position=new.p
  43.     if keys.w then
  44.      gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(-math.rad(speed*15),0,0)
  45.     elseif keys.s then
  46.      gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(math.rad(speed*15),0,0)
  47.     else
  48.      gyro.cframe = workspace.CurrentCamera.CoordinateFrame
  49.     end
  50.    until not Fly
  51.    if gyro then gyro:Destroy() end
  52.    if pos then pos:Destroy() end
  53.    flying=false
  54.    localplayer.Character.Humanoid.PlatformStand=false
  55.    speed=0
  56.   end
  57.   e1=mouse.KeyDown:connect(function(key)
  58.    if not torso or not torso.Parent then flying=false e1:disconnect() e2:disconnect() return end
  59.    if key=="w" then
  60.     keys.w=true
  61.    elseif key=="s" then
  62.     keys.s=true
  63.    elseif key=="a" then
  64.     keys.a=true
  65.    elseif key=="d" then
  66.     keys.d=true
  67.    end
  68.   end)
  69.   e2=mouse.KeyUp:connect(function(key)
  70.    if key=="w" then
  71.     keys.w=false
  72.  elseif key=="e" then
  73. if Fly == true then
  74.     Fly = false
  75. else
  76.     Fly = true
  77.     start()
  78. end
  79.    elseif key=="s" then
  80.     keys.s=false
  81.    elseif key=="a" then
  82.     keys.a=false
  83.    elseif key=="d" then
  84.     keys.d=false
  85.    end
  86.   end)
  87.  
  88.  game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
  89.     torso = char:WaitForChild("HumanoidRootPart")
  90. end)
  91.  
  92.  
  93.   start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement