Vzurxy

funny ball

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