Advertisement
HowToRoblox

KnockbackToolHandler

Nov 12th, 2021
4,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. local cooldown = false
  2.  
  3.  
  4. script.Parent.Activated:Connect(function()
  5.    
  6.     if cooldown then return end
  7.    
  8.     cooldown = true
  9.    
  10.    
  11.     local ray = Ray.new(script.Parent.Parent.HumanoidRootPart.Position, script.Parent.Parent.HumanoidRootPart.Position + script.Parent.Parent.HumanoidRootPart.CFrame.LookVector * 5)
  12.    
  13.     local part = workspace:FindPartOnRay(ray, script.Parent.Parent)
  14.    
  15.    
  16.     if part then
  17.        
  18.         local humanoid = part.Parent:FindFirstChild("Humanoid") or part.Parent.Parent:FindFirstChild("Humanoid")
  19.        
  20.         if humanoid then
  21.            
  22.             humanoid.Parent.HumanoidRootPart.Velocity = script.Parent.Parent.HumanoidRootPart.CFrame.LookVector * 100 + Vector3.new(0, 50, 0)
  23.         end
  24.     end
  25.    
  26.    
  27.     wait(1)
  28.    
  29.     cooldown = false
  30. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement