Advertisement
eea

dodge

eea
Oct 2nd, 2022 (edited)
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local char = owner.Character
  2. local ta = {workspace.Base}
  3. local plrs = game:GetService("Players")
  4. for i = 1,#plrs:GetChildren() do
  5.     if plrs:children()[i]:IsA("Player") then
  6.         ta[#ta+1] = plrs:children()[i].Character
  7.     end
  8. end
  9. plrs.PlayerAdded:Connect(function(plr)
  10.     ta[#ta+1] = plr.Character
  11. end)
  12. plrs.PlayerRemoving:Connect(function(plr)
  13.     table.remove(ta, table.find(ta, plr.Name))
  14. end)
  15.  
  16. function angle(v1, v2)
  17.     return math.asin(v1:Dot(v2)/(v1.Magnitude*v2.Magnitude))
  18. end
  19.  
  20. function speed(p, c)
  21.     return (p - c.Position).Magnitude/c.Velocity.Magnitude
  22. end
  23.  
  24. while task.wait() do
  25.     local param = OverlapParams.new()
  26.     param.FilterDescendantsInstances = ta
  27.     param.FilterType = Enum.RaycastFilterType.Blacklist
  28.     local pa = workspace:GetPartBoundsInRadius(char.HumanoidRootPart.Position, 40, param)
  29.     for i = 1,#pa do
  30.         local c = pa[i]
  31.         pcall(function() if speed(char.HumanoidRootPart.Position, c) < 1.1 and angle(char.HumanoidRootPart.Position - c.Position, c.Velocity) < 20 then
  32.             char.HumanoidRootPart.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position, c.Position)
  33.             char.HumanoidRootPart.Position += char.HumanoidRootPart.CFrame.RightVector *10
  34.         end end)
  35.     end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement