princeofheaven

ForceField

Aug 2nd, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.59 KB | None | 0 0
  1. --[[ Exoshield - Made by Despairus ]]
  2. script.Parent = nil
  3. script.Name = "Exoshield"
  4. Username = "PrinceOfHeaven" -- PUT YOUR NAME HERE
  5. local RS = game:GetService("RunService")
  6.  
  7. function getparts(t, range, location)
  8. local parts = {}
  9. for _a,a in pairs(location:GetChildren()) do
  10. if (a.Name ~= "ExoShield") then
  11. if (a:IsA("BasePart")) then
  12. if ((a.Position-t.Position).magnitude <= range) then--[[ and (a.Position-t.Position).magnitude > (range/1.5)) then]]
  13. table.insert(parts, a)
  14. end
  15. elseif (a.ClassName == "Model" and a ~= t.Parent) then
  16. if (a:FindFirstChild("Torso") and a:FindFirstChild("Humanoid")) then
  17. if ((a.Torso.Position-t.Position).magnitude <= range) then--[[ and (a.Position-t.Position).magnitude > (range/1.5)) then]]
  18. table.insert(parts, a.Torso)
  19. end
  20. end
  21. end
  22. end
  23. end
  24. return parts
  25. end
  26.  
  27. CreateExoShield = function(User)
  28. if User ~= nil then
  29. if User.Character ~= nil then
  30. if User.Character:FindFirstChild("Exoshield") == nil then
  31. local rendercon = nil
  32. local distance = 8
  33. local mode = "barrier"
  34. local angle = 0
  35. local _e1,e1 = 0,false
  36. local shield = Instance.new("Part")
  37. local light = Instance.new("PointLight")
  38. local forcefield = Instance.new("Part")
  39. local spheremesh = Instance.new("SpecialMesh")
  40. local m = Instance.new("Model")
  41.  
  42. while coroutine.yield() do --[[rendercon = RS.Heartbeat:connect(function()]]
  43. if User == nil then rendercon:disconnect() end
  44. if (angle < 100) then angle = angle + .03 else angle = 0 end
  45. if m == nil then m = Instance.new("Model") end
  46. if shield == nil then shield = Instance.new("Part") end
  47. if light == nil then light = Instance.new("PointLight") end
  48. if forcefield == nil then forcefield = Instance.new("Part") end
  49. if spheremesh == nil then spheremesh = Instance.new("SpecialMesh") end
  50. m.Parent = game.Workspace
  51. m.Name = "ExoShield"
  52. shield.Parent = m
  53. shield.FormFactor = "Custom"
  54. shield.BottomSurface = 0
  55. shield.Material = "DiamondPlate"
  56. shield.TopSurface = 0
  57. shield.Name = "Shield"
  58. shield.BrickColor = BrickColor.new("Toothpaste")
  59. shield.Locked = true
  60. shield.Size = Vector3.new(6+(_e1/14),.6+(_e1/18),6+(_e1/14))
  61. shield.Anchored = true
  62. shield.Velocity = Vector3.new(0,0,-200)
  63. shield.Transparency = (1 - (_e1 * .03))
  64. light.Parent = shield
  65. forcefield.Parent = m
  66. forcefield.Name = "ForceField"
  67. forcefield.FormFactor = "Custom"
  68. forcefield.Material = "Slate"
  69. forcefield.CanCollide = false
  70. forcefield.Size = Vector3.new((distance*2)+(_e1/16),(distance*2)+(_e1/16),(distance*2)+(_e1/16))
  71. forcefield.Anchored = true
  72. forcefield.Locked = true
  73. forcefield.BottomSurface = 0
  74. forcefield.TopSurface = 0
  75. forcefield.BrickColor = BrickColor.new("Really black")
  76. forcefield.Transparency = (1 - (_e1 * .04))
  77. spheremesh.Parent = forcefield
  78. spheremesh.MeshType = "Sphere"
  79.  
  80. if e1 then
  81. _e1=_e1-.3
  82. else
  83. _e1=_e1+.3
  84. end
  85. if (_e1 < 0) then
  86. e1 = false
  87. elseif (_e1 > 10) then
  88. e1 = true
  89. end
  90.  
  91. if User.Character ~= nil then
  92. for _,v in pairs(User.Character:GetChildren()) do
  93. local c = v.ClassName
  94. if (v:IsA("BasePart")) then
  95. v.Material = "Marble"
  96. v.BrickColor = BrickColor.new("Black")
  97.  
  98. if (v.Name == "Head" and User.Character:findFirstChild("Fakehead") == nil) then
  99. if (v:findFirstChild("face")) then
  100. v.face:Destroy()
  101. end
  102.  
  103. local fakehead = v:Clone()
  104. fakehead.Name = "Fakehead"
  105. fakehead.Parent = User.Character
  106. local w = Instance.new("Weld", v)
  107. w.Part0 = v
  108. w.Part1 = fakehead
  109. v.Transparency = 1
  110. end
  111. elseif (c == "Hat" or c == "Shirt" or c == "Pants") then
  112. v:Destroy()
  113. elseif (c == "Humanoid") then
  114. v.MaxHealth = 999999999
  115. v.Health = v.MaxHealth
  116. v.WalkSpeed = 30
  117. v.PlatformStand = false
  118. v.Sit = false
  119. v.Jump = false
  120. end
  121. end
  122.  
  123. local t = User.Character:FindFirstChild("Torso")
  124. if t ~= nil then
  125. if (mode == "barrier") then
  126. local objects,x,y,z = getparts(t,distance,Workspace),0,0,0
  127. if (#objects > 0) then
  128. for _,v in pairs(objects) do
  129. shield.CFrame = CFrame.new(t.Position, v.Position) * CFrame.new(0,0,-distance/2) * CFrame.Angles(math.pi/2,0,0)
  130. end
  131. else
  132. x = math.sin(angle / math.pi*2) * (distance/2)
  133. z = math.cos(angle / math.pi*2) * (distance/2)
  134. y = 0 --[[ Todo; add rotation to y matrix ]]
  135. shield.CFrame = CFrame.new(t.Position, t.Position+Vector3.new(x,y,z)) * CFrame.new(0,0,-distance) * CFrame.Angles(math.pi/2,0,0)
  136. end
  137. forcefield.CFrame = t.CFrame
  138. end
  139. end
  140. end
  141. end --[[ END LOOP ]]
  142. end
  143. end
  144. end
  145. end
  146.  
  147. CreateExoShield(game.Players[Username])
  148.  
  149. game.Players[Username].Chatted:connect(function(msg)
  150. if (string.sub(msg:lower(), 1, 7) == "shield ") then
  151. local name = string.sub(msg:lower(), 8)
  152. for _,v in pairs(game.Players:GetPlayers()) do
  153. if (string.find(v.Name:lower(), name)) then
  154. CreateExoShield(v)
  155. end
  156. end
  157. end
  158. end)
Add Comment
Please, Sign In to add comment