TheUnknownDiscord

force field remake

Oct 11th, 2021 (edited)
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. part = function()
  2.  
  3. local a = Instance.new("Part", owner.Character)
  4. a.CanCollide = false
  5. a.Size = Vector3.new(6.5, 6.5, 6.5)
  6. a.Color = Color3.fromRGB(184, 65, 65)
  7. a.Transparency = 0.7
  8. a.Material = "Neon"
  9. local b = Instance.new("BodyVelocity", a)
  10. b.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  11. b.Velocity = Vector3.new()
  12. a:SetNetworkOwner(owner)
  13. return a
  14. end
  15. part2 = function()
  16.  
  17. local a = Instance.new("Part", owner.Character)
  18. a.CanCollide = false
  19. a.Size = Vector3.new(6.7, 6.7, 6.7)
  20. a.Color = Color3.fromRGB(120, 6, 6)
  21. a.Transparency = 0.85
  22. a.Material = Enum.Material.ForceField
  23. local b = Instance.new("BodyVelocity", a)
  24. b.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  25. b.Velocity = Vector3.new()
  26. a:SetNetworkOwner(owner)
  27. return a
  28. end
  29. local replicating = false
  30. local root, a, b, c, d = nil, nil, nil, nil, nil
  31. replicate = function()
  32.  
  33. replicating = true
  34. script:ClearAllChildren()
  35. root = part()
  36. root.Transparency = 1
  37. root.Size = Vector3.new(0.2, 0.2, 0.2)
  38. root.CanCollide = false
  39. a = part()
  40. b = part()
  41. c = part2()
  42. d = part2()
  43. replicating = false
  44. wait()
  45. weld1 = Instance.new("Weld", a)
  46. weld1.Part0 = a
  47. weld1.Part1 = c
  48. weld2 = Instance.new("Weld", b)
  49. weld2.Part0 = b
  50. weld2.Part1 = d
  51. end
  52.  
  53. script.ChildRemoved:connect(function(a)
  54.  
  55. if a.ClassName == "Part" and replicating == false then
  56. replicate()
  57. end
  58. end
  59. )
  60. replicate()
  61. CreateRegion3FromLocAndSize = function(Position, Size)
  62.  
  63. local SizeOffset = Size / 2
  64. local Point1 = Position - SizeOffset
  65. local Point2 = Position + SizeOffset
  66. return Region3.new(Point1, Point2)
  67. end
  68. local vel
  69. game:GetService("RunService").Heartbeat:connect(function()
  70.  
  71. pcall(function()
  72. root.CFrame = owner.Character.HumanoidRootPart.CFrame
  73. a.CFrame = owner.Character.HumanoidRootPart.CFrame
  74. b.CFrame = owner.Character.HumanoidRootPart.CFrame
  75. c.CFrame = owner.Character.HumanoidRootPart.CFrame
  76. d.CFrame = owner.Character.HumanoidRootPart.CFrame
  77. local void = owner.Character:GetDescendants()
  78. local reg = CreateRegion3FromLocAndSize(owner.Character.HumanoidRootPart.CFrame.p, Vector3.new(6.5, 6.5, 6.5))
  79. for i,v in pairs(game.Workspace:FindPartsInRegion3WithIgnoreList(reg, void, math.huge * -math.huge)) do
  80. if v.Name ~= "Base" then
  81. v:Destroy()
  82. end
  83. end
  84. end)
  85. end)
RAW Paste Data