Advertisement
MasonWall19

Untitled

Jun 18th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. --[[
  2. Instructions:
  3. 1. Put this script inside "StarterGui"
  4. 2. Only edit anything under the "Settings" tab.
  5. 3. Happy rolling!
  6.  
  7. --Warriorqaz || <AstroCode/>
  8. --]]
  9.  
  10. --//Wait
  11. Player = game.Players.LocalPlayer
  12. repeat wait() until Player.Character
  13. Mouse = Player:GetMouse()
  14. Camera = game.Workspace.CurrentCamera
  15. Character = Player.Character
  16. Torso = Character:WaitForChild("Torso")
  17. Humanoid = Character:WaitForChild("Humanoid")
  18.  
  19. --//Initialize
  20. local Ball = Instance.new("Part")
  21. Ball.Anchored = false
  22. Ball.CanCollide = true
  23. Ball.FormFactor = Enum.FormFactor.Symmetric
  24. Ball.Shape = Enum.PartType.Ball
  25. Ball.Size = Vector3.new(8, 8, 8)
  26. Ball.TopSurface = Enum.SurfaceType.SmoothNoOutlines
  27. Ball.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
  28.  
  29. Ball.CFrame = Torso.CFrame
  30. local Weld = Instance.new("Weld", Ball)
  31. Weld.Part0 = Ball
  32. Weld.Part1 = Torso
  33.  
  34. Ball.Parent = Character
  35. Humanoid.Sit = true
  36.  
  37. Camera.CameraType = Enum.CameraType.Track
  38. Camera.CameraSubject = Ball
  39.  
  40. Direction = {W = 0, A = 0, S = 0, D = 0}
  41.  
  42. --//Settings
  43. MaxVelocity = 100 -- Maximum marble speed
  44. Acceleration = 5 -- Rate at which speed changes
  45.  
  46. Ball.Elasticity = 0 -- Bounciness (0 - 1)
  47. Ball.Friction = 1 -- How well it sticks to the ground (0 - 2)
  48. Ball.Transparency = 0.5
  49. Ball.BrickColor = BrickColor.new("White")
  50. Ball.Material = Enum.Material.Marble
  51.  
  52. --//Functions
  53. function Parameters()
  54. if Character and Torso and Humanoid and Ball then
  55. return true
  56. else
  57. return false
  58. end
  59. end
  60.  
  61. function Down(Key)
  62. if Key == "w" then
  63. Direction.W = true
  64. while Direction.W do
  65. Ball.Velocity = Ball.Velocity + (Camera.CoordinateFrame.lookVector * Acceleration)
  66. wait()
  67. end
  68. elseif Key == "a" then
  69. Direction.A = true
  70. while Direction.A do
  71. Ball.Velocity = Ball.Velocity + ((Camera.CoordinateFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector * Acceleration)
  72. wait()
  73. end
  74. elseif Key == "s" then
  75. Direction.S = true
  76. while Direction.S do
  77. Ball.Velocity = Ball.Velocity + (Camera.CoordinateFrame.lookVector * -Acceleration)
  78. wait()
  79. end
  80. elseif Key == "d" then
  81. Direction.D = true
  82. while Direction.D do
  83. Ball.Velocity = Ball.Velocity + ((Camera.CoordinateFrame * CFrame.Angles(0, math.rad(-90), 0)).lookVector * Acceleration)
  84. wait()
  85. end
  86. end
  87. end
  88.  
  89. function Up(Key)
  90. if Key == "w" then
  91. Direction.W = false
  92. elseif Key == "a" then
  93. Direction.A = false
  94. elseif Key == "s" then
  95. Direction.S = false
  96. elseif Key == "d" then
  97. Direction.D = false
  98. elseif Key == "e" then
  99. Direction.W, Direction.A, Direction.S, Direction.D = false, false, false, false
  100. Ball.Velocity = Vector3.new(0, 0, 0)
  101. end
  102. end
  103.  
  104. function BallChanged()
  105. if Ball.Velocity.X > MaxVelocity then Ball.Velocity = Vector3.new(MaxVelocity, Ball.Velocity.Y, Ball.Velocity.Z)
  106. elseif Ball.Velocity.X < -MaxVelocity then Ball.Velocity = Vector3.new(-MaxVelocity, Ball.Velocity.Y, Ball.Velocity.Z)
  107. elseif Ball.Velocity.Y > MaxVelocity then Ball.Velocity = Vector3.new(Ball.Velocity.X, MaxVelocity, Ball.Velocity.Z)
  108. elseif Ball.Velocity.Y < -MaxVelocity then Ball.Velocity = Vector3.new(Ball.Velocity.X, -MaxVelocity, Ball.Velocity.Z)
  109. elseif Ball.Velocity.Z > MaxVelocity then Ball.Velocity = Vector3.new(Ball.Velocity.X, Ball.Velocity.Y, MaxVelocity)
  110. elseif Ball.Velocity.Z < -MaxVelocity then Ball.Velocity = Vector3.new(Ball.Velocity.X, Ball.Velocity.Y, -MaxVelocity)
  111. end
  112. end
  113.  
  114. function HumanoidChanged() -- Prevents players from standing up
  115. Humanoid.Jump = false
  116. Humanoid.Sit = true
  117. end
  118.  
  119. function HumanoidDied()
  120. Ball:Destroy()
  121. end
  122.  
  123. --//Logic
  124. Mouse.KeyDown:connect(Down)
  125. Mouse.KeyUp:connect(Up)
  126.  
  127. Ball.Changed:connect(BallChanged)
  128.  
  129. Humanoid.Changed:connect(HumanoidChanged)
  130. Humanoid.Died:connect(HumanoidDied)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement