StrawberryMemester

Roblox Cube Force Field Script

Mar 23rd, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. local p = game.Players.LocalPlayer
  2. local char = p.Character
  3. local size = 8
  4. part = function()
  5.  
  6. local a = Instance.new("Part", script)
  7. a.Anchored = true
  8. a.CanCollide = true
  9. a.CFrame = char.Torso.CFrame
  10. a.Size = Vector3.new(size, 0.2, 0.2)
  11. a.Transparency = 1
  12. return a
  13. end
  14.  
  15. part2 = function()
  16.  
  17. local a = Instance.new("Part", script)
  18. a.Anchored = true
  19. a.CanCollide = true
  20. a.CFrame = char.Torso.CFrame
  21. a.Size = Vector3.new(0.2, size, 0.2)
  22. a.Transparency = 1
  23. return a
  24. end
  25.  
  26. part3 = function()
  27.  
  28. local a = Instance.new("Part", script)
  29. a.Anchored = true
  30. a.CanCollide = false
  31. a.Size = Vector3.new(size, size, 1)
  32. a.Transparency = 0.7
  33. a.Material = "Neon"
  34. a.BrickColor = BrickColor.new("Really red")
  35. local b = Instance.new("BlockMesh", a)
  36. b.Scale = Vector3.new(1, 1, 0)
  37. return a
  38. end
  39.  
  40. local replicating = false
  41. local root, a, b, c, d, a2, b2, c2, d2, aa, bb, cc, dd, z, x, c, v, b, n = nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil
  42. replicate = function()
  43.  
  44. replicating = true
  45. script:ClearAllChildren()
  46. root = part()
  47. root.Transparency = 1
  48. root.Size = Vector3.new(0.2, 0.2, 0.2)
  49. root.CanCollide = false
  50. a = part()
  51. b = part()
  52. c = part()
  53. d = part()
  54. a2 = part()
  55. b2 = part()
  56. c2 = part()
  57. d2 = part()
  58. aa = part2()
  59. bb = part2()
  60. cc = part2()
  61. dd = part2()
  62. z = part3()
  63. x = part3()
  64. c = part3()
  65. v = part3()
  66. b = part3()
  67. n = part3()
  68. replicating = false
  69. end
  70.  
  71. script.ChildRemoved:connect(function(a)
  72.  
  73. if a.ClassName == "Part" and replicating == false then
  74. replicate()
  75. end
  76. end
  77. )
  78. replicate()
  79. local tick = 0
  80. CreateRegion3FromLocAndSize = function(Position, Size)
  81.  
  82. local SizeOffset = Size / 2
  83. local Point1 = Position - SizeOffset
  84. local Point2 = Position + SizeOffset
  85. return Region3.new(Point1, Point2)
  86. end
  87.  
  88. local set = false
  89. local whitelist = {"Hieroku", "PPATTA", "DevGamerzz", "I kill U", "kash5", "ZeroCrimson", "Zaidia", "tsup2", "PointCoded", "CLarramore", "Suzuuki", "", "", ""}
  90. p.Chatted:connect(function(ms)
  91.  
  92. if ms:sub(1, 5) == "size-" then
  93. size = tonumber(ms:sub(6))
  94. replicate()
  95. else
  96. if ms:sub(1, 4) == "set-" then
  97. set = true
  98. z.CanCollide = false
  99. x.CanCollide = false
  100. c.CanCollide = false
  101. v.CanCollide = false
  102. b.CanCollide = false
  103. n.CanCollide = false
  104. else
  105. if ms:sub(1, 6) == "unset-" then
  106. set = false
  107. z.CanCollide = false
  108. x.CanCollide = false
  109. c.CanCollide = false
  110. v.CanCollide = false
  111. b.CanCollide = false
  112. n.CanCollide = false
  113. else
  114. if ms:sub(1, 10) == "whitelist-" then
  115. table.insert(whitelist, ms:sub(11))
  116. else
  117. if ms:sub(1, 12) == "unwhitelist-" then
  118. for i,v in pairs(whitelist) do
  119. if ms:sub(13) == v then
  120. table.remove(whitelist, i)
  121. break
  122. end
  123. end
  124. end
  125. end
  126. end
  127. end
  128. end
  129. end
  130. )
  131. local magicpos = nil
  132. game:GetService("RunService").Heartbeat:connect(function()
  133.  
  134. pcall(function()
  135.  
  136. local void = char:GetChildren()
  137. for _,pl in pairs(whitelist) do
  138. if game.Players:FindFirstChild(pl) ~= nil and game.Players:FindFirstChild(pl).Character ~= nil then
  139. for i,v in pairs(game.Players[pl].Character:GetChildren()) do
  140. table.insert(void, v)
  141. end
  142. end
  143. end
  144. for i,v in pairs(game.Players:GetPlayers()) do
  145. if v.Character:isDescendantOf(char) and not v.Name == "FangxWulf" then
  146. v:LoadCharacter()
  147. end
  148. end
  149. char.Humanoid.Health = math.huge
  150. tick = tick + 0.01
  151. if not set then
  152. root.CFrame = root.CFrame:lerp(CFrame.new(char.Torso.CFrame.p) * CFrame.Angles(math.sin(tick) * 100 / 30 / (size / 2), math.cos(tick) * 100 / 30 / (size / 2), math.cos(tick) * 100 / 30 / (size / 2)), 0.1)
  153. magicpos = char.Torso.CFrame
  154. else
  155. root.CFrame = root.CFrame:lerp(CFrame.new(magicpos.p) * CFrame.Angles(0, 0, 0), 0.05)
  156. end
  157. local reg = CreateRegion3FromLocAndSize(root.CFrame.p, Vector3.new(size, size, size))
  158. for i,v in pairs(game.Workspace:FindPartsInRegion3WithIgnoreList(reg, void, 100)) do
  159. if v.Name ~= "Base" then
  160. v:Destroy()
  161. end
  162. end
  163. a.CFrame = root.CFrame * CFrame.new(size / 2, size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  164. b.CFrame = root.CFrame * CFrame.new(-size / 2, size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  165. c.CFrame = root.CFrame * CFrame.new(0, size / 2, size / 2)
  166. d.CFrame = root.CFrame * CFrame.new(0, size / 2, -size / 2)
  167. a2.CFrame = root.CFrame * CFrame.new(size / 2, -size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  168. b2.CFrame = root.CFrame * CFrame.new(-size / 2, -size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  169. c2.CFrame = root.CFrame * CFrame.new(0, -size / 2, size / 2)
  170. d2.CFrame = root.CFrame * CFrame.new(0, -size / 2, -size / 2)
  171. aa.CFrame = root.CFrame * CFrame.new(size / 2, 0, size / 2)
  172. bb.CFrame = root.CFrame * CFrame.new(-size / 2, 0, size / 2)
  173. cc.CFrame = root.CFrame * CFrame.new(-size / 2, 0, -size / 2)
  174. dd.CFrame = root.CFrame * CFrame.new(size / 2, 0, -size / 2)
  175. z.CFrame = root.CFrame * CFrame.new(size / 2, 0, 0) * CFrame.Angles(0, math.rad(90), 0)
  176. x.CFrame = root.CFrame * CFrame.new(-size / 2, 0, 0) * CFrame.Angles(0, math.rad(90), 0)
  177. c.CFrame = root.CFrame * CFrame.new(0, 0, size / 2) * CFrame.Angles(0, 0, math.rad(90))
  178. v.CFrame = root.CFrame * CFrame.new(0, 0, -size / 2) * CFrame.Angles(0, 0, math.rad(90))
  179. b.CFrame = root.CFrame * CFrame.new(0, size / 2, 0) * CFrame.Angles(math.rad(90), 0, 0)
  180. n.CFrame = root.CFrame * CFrame.new(0, -size / 2, 0) * CFrame.Angles(math.rad(90), 0, 0)
  181. end
  182. )
  183. end
  184. )
Add Comment
Please, Sign In to add comment