HowToRoblox

BasketballServer

May 9th, 2021 (edited)
559
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tool = script.Parent
  2. local re = tool:WaitForChild("BasketballRE")
  3.  
  4. local cooldown = false
  5.  
  6.  
  7. local ps = game:GetService("PhysicsService")
  8. ps:CreateCollisionGroup("Ball")
  9. ps:CreateCollisionGroup("Character")
  10. ps:CollisionGroupSetCollidable("Character", "Ball", false)
  11.  
  12.  
  13. re.OnServerEvent:Connect(function(plr, mouseHit)
  14.    
  15.     local char = plr.Character
  16.     local hum = char:FindFirstChild("Humanoid")
  17.    
  18.    
  19.     if hum and not cooldown then
  20.  
  21.         cooldown = true
  22.        
  23.         hum.Jump = true
  24.        
  25.         local ballClone = tool.Handle:Clone()
  26.         ballClone.Transparency = 0
  27.         tool.Handle.Transparency = 1
  28.        
  29.        
  30.         for i, descendant in pairs(plr.Character:GetDescendants()) do
  31.             if descendant:IsA("BasePart") then ps:SetPartCollisionGroup(descendant, "Character") end
  32.         end
  33.         ps:SetPartCollisionGroup(ballClone, "Ball")
  34.        
  35.        
  36.         local velocity = mouseHit.Position + Vector3.new(0, game.Workspace.Gravity * 0.5, 0)
  37.         ballClone.Velocity = velocity
  38.        
  39.         ballClone.CanCollide = true
  40.         ballClone.Parent = workspace
  41.        
  42.        
  43.         game:GetService("Debris"):AddItem(ballClone, 120)
  44.        
  45.         wait(5)
  46.         ballClone.Velocity = Vector3.new(0, 0, 0)
  47.         tool.Handle.Transparency = 0
  48.         cooldown = false
  49.     end
  50. end)
RAW Paste Data