choco99

Untitled

Dec 22nd, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. down = false
  2. velocity = Instance.new("BodyVelocity")
  3. velocity.maxForce = Vector3.new(100000, 0, 100000)
  4. local speed = 100
  5. gyro = Instance.new("BodyGyro")
  6. gyro.maxTorque = Vector3.new(100000, 0, 100000)
  7.  
  8. local hum = game.Players.LocalPlayer.Character.Humanoid
  9.  
  10. function onButton1Down(mouse)
  11. down = true
  12. velocity.Parent = game.Players.LocalPlayer.Character.UpperTorso
  13. velocity.velocity = (hum.MoveDirection) * speed
  14. gyro.Parent = game.Players.LocalPlayer.Character.UpperTorso
  15. while down do
  16. if not down then break end
  17. velocity.velocity = (hum.MoveDirection) * speed
  18. local refpos = gyro.Parent.Position + (gyro.Parent.Position - workspace.CurrentCamera.CoordinateFrame.p).unit * 5
  19. gyro.cframe = CFrame.new(gyro.Parent.Position, Vector3.new(refpos.x, gyro.Parent.Position.y, refpos.z))
  20. wait(0.1)
  21. end
  22. end
  23.  
  24. function onButton1Up(mouse)
  25. velocity.Parent = nil
  26. gyro.Parent = nil
  27. down = false
  28. end
  29.  
  30. function onSelected(mouse)
  31. mouse.KeyDown:connect(function(k) if k:lower()=="q"then onButton1Down(mouse)end end)
  32. mouse.KeyUp:connect(function(k) if k:lower()=="q"then onButton1Up(mouse)end end)
  33. end
  34.  
  35. onSelected(game.Players.LocalPlayer:GetMouse())
Advertisement
Add Comment
Please, Sign In to add comment