HowToRoblox

BoulderCreator

Aug 1st, 2021 (edited)
1,034
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local re = game.ReplicatedStorage:WaitForChild("BoulderRE")
  2.  
  3.  
  4. local plrsOnCooldown = {}
  5.  
  6.  
  7. local ts = game:GetService("TweenService")
  8.  
  9.  
  10.  
  11. re.OnServerEvent:Connect(function(plr)
  12.  
  13.  
  14.     if plrsOnCooldown[plr] then return end
  15.  
  16.     plrsOnCooldown[plr] = true
  17.  
  18.  
  19.     local hrp = plr.Character:WaitForChild("HumanoidRootPart")
  20.  
  21.  
  22.     local startPos = hrp.Position + (hrp.CFrame.LookVector * 5) - Vector3.new(0, hrp.Size.Y * 1.5, 0)
  23.    
  24.    
  25.     local boulder = script:WaitForChild("Boulder"):Clone()
  26.    
  27.     boulder.Size = Vector3.new(0, 0, 0)
  28.     boulder.Position = startPos
  29.    
  30.     boulder.Anchored = true
  31.     boulder.CanCollide = false
  32.    
  33.    
  34.     boulder.Parent = workspace
  35.    
  36.    
  37.     local newPos = startPos + Vector3.new(0, 10, 0)
  38.     local newSize = Vector3.new(7, 7, 7)
  39.    
  40.    
  41.     local ti = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
  42.    
  43.     local liftTween = ts:Create(boulder, ti, {Position = newPos, Size = newSize})
  44.     liftTween:Play()
  45.    
  46.     liftTween.Completed:Wait()
  47.    
  48.    
  49.     local bv = Instance.new("BodyVelocity", boulder)
  50.     bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  51.    
  52.     local bav = Instance.new("BodyAngularVelocity", boulder)
  53.     bav.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  54.    
  55.    
  56.     boulder.Anchored = false
  57.     boulder.CanCollide = true
  58.    
  59.    
  60.     boulder:SetNetworkOwner(plr)
  61.    
  62.     re:FireClient(plr, boulder)
  63.    
  64.    
  65.     local hitChars = {}
  66.    
  67.    
  68.     boulder.Touched:Connect(function(hit)
  69.            
  70.         bv:Destroy()
  71.         bav:Destroy()
  72.        
  73.         boulder:SetNetworkOwner(nil)
  74.        
  75.        
  76.         if hit.Parent ~= plr.Character then
  77.            
  78.            
  79.             if hit.Parent:FindFirstChild("Humanoid") and not hitChars[hit.Parent] then
  80.                
  81.                 hitChars[hit.Parent] = true
  82.                
  83.                 hit.Parent.Humanoid:TakeDamage(40)
  84.             end
  85.         end
  86.     end)
  87.    
  88.    
  89.     game:GetService("Debris"):AddItem(boulder, 30)
  90.    
  91.  
  92.     wait(1)
  93.  
  94.     plrsOnCooldown[plr] = nil
  95. end)
RAW Paste Data