Advertisement
robloxboblox

Untitled

Dec 4th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. local UserInputService = game:GetService("UserInputService")
  2. local RunService = game:GetService("RunService")
  3. local Camera = workspace.CurrentCamera
  4.  
  5. local SPEED_MULTIPLIER = 30
  6. local JUMP_POWER = 60
  7. local JUMP_GAP = 0.3
  8.  
  9. local character = game.Players.LocalPlayer.Character
  10.  
  11. for i,v in ipairs(character:GetDescendants()) do
  12. if v:IsA("BasePart") then
  13. v.CanCollide = false
  14. end
  15. end
  16.  
  17. local ball = character.HumanoidRootPart
  18. ball.Shape = Enum.PartType.Ball
  19. ball.Size = Vector3.new(5,5,5)
  20. local humanoid = character:WaitForChild("Humanoid")
  21. local params = RaycastParams.new()
  22. params.FilterType = Enum.RaycastFilterType.Blacklist
  23. params.FilterDescendantsInstances = {character}
  24.  
  25. local tc = RunService.RenderStepped:Connect(function(delta)
  26. ball.CanCollide = true
  27. humanoid.PlatformStand = true
  28. if UserInputService:GetFocusedTextBox() then return end
  29. if UserInputService:IsKeyDown("W") then
  30. ball.RotVelocity -= Camera.CFrame.RightVector * delta * SPEED_MULTIPLIER
  31. end
  32. if UserInputService:IsKeyDown("A") then
  33. ball.RotVelocity -= Camera.CFrame.LookVector * delta * SPEED_MULTIPLIER
  34. end
  35. if UserInputService:IsKeyDown("S") then
  36. ball.RotVelocity += Camera.CFrame.RightVector * delta * SPEED_MULTIPLIER
  37. end
  38. if UserInputService:IsKeyDown("D") then
  39. ball.RotVelocity += Camera.CFrame.LookVector * delta * SPEED_MULTIPLIER
  40. end
  41. --ball.RotVelocity = ball.RotVelocity - Vector3.new(0,ball.RotVelocity.Y/50,0)
  42. end)
  43.  
  44. UserInputService.JumpRequest:Connect(function()
  45. local result = workspace:Raycast(
  46. ball.Position,
  47. Vector3.new(
  48. 0,
  49. -((ball.Size.Y/2)+JUMP_GAP),
  50. 0
  51. ),
  52. params
  53. )
  54. if result then
  55. ball.Velocity = ball.Velocity + Vector3.new(0,JUMP_POWER,0)
  56. end
  57. end)
  58.  
  59. Camera.CameraSubject = ball
  60. humanoid.Died:Connect(function() tc:Disconnect() end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement