Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. local power = 10
  2. wait()
  3. bin = script.Parent
  4. bpos = Instance.new("BodyPosition")
  5. gyro = Instance.new("BodyGyro")
  6. gyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  7. bpos.maxForce = Vector3.new(math.huge,math.huge,math.huge)
  8. fly = false
  9. player = T8NRfrags
  10. char = player.Character.Torso
  11. airborne = false
  12.  
  13. function onButton1Down(mouse)
  14. fly = true
  15. while fly do
  16. pos = mouse.Hit.p
  17. --gyro.cframe = CFrame.new(char.Position,pos)
  18. bpos.position = char.Position + (pos-char.Position).unit * power
  19. wait()
  20. end
  21. end
  22.  
  23. function onMove(mouse)
  24. pos = mouse.Hit.p
  25. gyro.cframe = CFrame.new(char.Position,pos) * CFrame.fromEulerAnglesXYZ(-3.14/2+1.2,0,0)
  26. --bpos.position = char.Position +
  27. --wait()
  28. --end
  29. end
  30.  
  31. function onButton1Up(mouse)
  32. fly = false
  33. end
  34.  
  35. function onSelected(mouse)
  36. print("select")
  37. if mouse == nil then
  38. return
  39. end
  40. airborne = true
  41. bpos.Parent = char
  42. bpos.position = char.Position + Vector3.new(0,10,0)
  43. gyro.Parent = char
  44. char.Parent.Humanoid.Sit = true
  45. mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
  46. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  47. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  48. mouse.Move:connect(function() onMove(mouse) end)
  49.  
  50. for i, v in ipairs(char:GetChildren()) do
  51. if v.className == "Motor" then
  52. v.MaxVelocity = 0
  53. v.CurrentAngle = -1
  54. if v.Name == "Left Hip" then
  55. v.CurrentAngle = 1
  56. end
  57. end
  58. end
  59. end
  60.  
  61. function onDeselected(mouse)
  62. print("deselect")
  63. gyro.Parent = nil
  64. fly = false
  65. airborne = false
  66. for i, v in ipairs(char:GetChildren()) do
  67. if v.className == "Motor" then
  68. v.MaxVelocity = 1
  69. end
  70. end
  71. char.Parent.Humanoid.Sit = false
  72. for i = 1, 30 do
  73. if not airborne then
  74. bpos.position = bpos.position - Vector3.new(0,0.3,0)
  75. wait(0.1)
  76. end
  77. end
  78. if not airborne then
  79. bpos.Parent = nil
  80. end
  81. end
  82.  
  83.  
  84. bin.Selected:connect(onSelected)
  85. bin.Deselected:connect(onDeselected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement