AndyWolf6610

Forcefield (AndyWolf6610 F.E)

May 20th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This script has been converted to FE by iPxter
  2.  
  3.  
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  6. do
  7. print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  8. script.Parent = Player.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent and t.Function then
  34. t.Function(...)
  35. end
  36. end
  37. m.TrigEvent = te
  38. UIS.TrigEvent = te
  39.  
  40. Event.OnServerEvent:Connect(function(plr,io)
  41. if plr~=Player then return end
  42. if io.isMouse then
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. else
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. for _,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59. end
  60. end)
  61. Event.Parent = NLS([==[
  62. local Player = game:GetService("Players").LocalPlayer
  63. local Event = script:WaitForChild("UserInput_Event")
  64.  
  65. local UIS = game:GetService("UserInputService")
  66. local input = function(io,a)
  67. if a then return end
  68. --Since InputObject is a client-side instance, we create and pass table instead
  69. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  70. end
  71. UIS.InputBegan:Connect(input)
  72. UIS.InputEnded:Connect(input)
  73.  
  74. local Mouse = Player:GetMouse()
  75. local h,t
  76. --Give the server mouse data 30 times every second, but only if the values changed
  77. --If player is not moving their mouse, client won't fire events
  78. while wait(1/30) do
  79. if h~=Mouse.Hit or t~=Mouse.Target then
  80. h,t=Mouse.Hit,Mouse.Target
  81. Event:FireServer({isMouse=true,Target=t,Hit=h})
  82. end
  83. end]==],Player.Character)
  84. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  85. end
  86.  
  87. local p = owner
  88. local char = p.Character
  89. local size = 8
  90. part = function()
  91.  
  92. local a = Instance.new("Part", script)
  93. a.Anchored = true
  94. a.CanCollide = true
  95. a.CFrame = char.Torso.CFrame
  96. a.Size = Vector3.new(size, 0.2, 0.2)
  97. a.Transparency = 1
  98. return a
  99. end
  100.  
  101. part2 = function()
  102.  
  103. local a = Instance.new("Part", script)
  104. a.Anchored = true
  105. a.CanCollide = true
  106. a.CFrame = char.Torso.CFrame
  107. a.Size = Vector3.new(0.2, size, 0.2)
  108. a.Transparency = 1
  109. return a
  110. end
  111.  
  112. part3 = function()
  113.  
  114. local a = Instance.new("Part", script)
  115. a.Anchored = true
  116. a.CanCollide = false
  117. a.Size = Vector3.new(size, size, 1)
  118. a.Transparency = 0.7
  119. a.Material = "Neon"
  120. a.BrickColor = BrickColor.new("Really red")
  121. local b = Instance.new("BlockMesh", a)
  122. b.Scale = Vector3.new(1, 1, 0)
  123. return a
  124. end
  125.  
  126. local replicating = false
  127. 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
  128. replicate = function()
  129.  
  130. replicating = true
  131. script:ClearAllChildren()
  132. root = part()
  133. root.Transparency = 1
  134. root.Size = Vector3.new(0.2, 0.2, 0.2)
  135. root.CanCollide = false
  136. a = part()
  137. b = part()
  138. c = part()
  139. d = part()
  140. a2 = part()
  141. b2 = part()
  142. c2 = part()
  143. d2 = part()
  144. aa = part2()
  145. bb = part2()
  146. cc = part2()
  147. dd = part2()
  148. z = part3()
  149. x = part3()
  150. c = part3()
  151. v = part3()
  152. b = part3()
  153. n = part3()
  154. replicating = false
  155. end
  156.  
  157. script.ChildRemoved:connect(function(a)
  158.  
  159. if a.ClassName == "Part" and replicating == false then
  160. replicate()
  161. end
  162. end
  163. )
  164. replicate()
  165. local tick = 0
  166. CreateRegion3FromLocAndSize = function(Position, Size)
  167.  
  168. local SizeOffset = Size / 2
  169. local Point1 = Position - SizeOffset
  170. local Point2 = Position + SizeOffset
  171. return Region3.new(Point1, Point2)
  172. end
  173.  
  174. local set = false
  175. local whitelist = {"Hieroku", "PPATTA", "DevGamerzz", "I kill U", "kash5", "ZeroCrimson", "Zaidia", "tsup2", "PointCoded", "CLarramore", "Suzuuki", "", "", ""}
  176. p.Chatted:connect(function(ms)
  177.  
  178. if ms:sub(1, 5) == "size-" then
  179. size = tonumber(ms:sub(6))
  180. replicate()
  181. else
  182. if ms:sub(1, 4) == "set-" then
  183. set = true
  184. z.CanCollide = false
  185. x.CanCollide = false
  186. c.CanCollide = false
  187. v.CanCollide = false
  188. b.CanCollide = false
  189. n.CanCollide = false
  190. else
  191. if ms:sub(1, 6) == "unset-" then
  192. set = false
  193. z.CanCollide = false
  194. x.CanCollide = false
  195. c.CanCollide = false
  196. v.CanCollide = false
  197. b.CanCollide = false
  198. n.CanCollide = false
  199. else
  200. if ms:sub(1, 10) == "whitelist-" then
  201. table.insert(whitelist, ms:sub(11))
  202. else
  203. if ms:sub(1, 12) == "unwhitelist-" then
  204. for i,v in pairs(whitelist) do
  205. if ms:sub(13) == v then
  206. table.remove(whitelist, i)
  207. break
  208. end
  209. end
  210. end
  211. end
  212. end
  213. end
  214. end
  215. end
  216. )
  217. local magicpos = nil
  218. game:GetService("RunService").Heartbeat:connect(function()
  219.  
  220. pcall(function()
  221.  
  222. local void = char:GetChildren()
  223. for _,pl in pairs(whitelist) do
  224. if game.Players:FindFirstChild(pl) ~= nil and game.Players:FindFirstChild(pl).Character ~= nil then
  225. for i,v in pairs(game.Players[pl].Character:GetChildren()) do
  226. table.insert(void, v)
  227. end
  228. end
  229. end
  230. for i,v in pairs(game.Players:GetPlayers()) do
  231. if v.Character:isDescendantOf(char) and not v.Name == "FangxWulf" then
  232. v:LoadCharacter()
  233. end
  234. end
  235. char.Humanoid.Health = math.huge
  236. tick = tick + 0.01
  237. if not set then
  238. 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)
  239. magicpos = char.Torso.CFrame
  240. else
  241. root.CFrame = root.CFrame:lerp(CFrame.new(magicpos.p) * CFrame.Angles(0, 0, 0), 0.05)
  242. end
  243. local reg = CreateRegion3FromLocAndSize(root.CFrame.p, Vector3.new(size, size, size))
  244. for i,v in pairs(game.Workspace:FindPartsInRegion3WithIgnoreList(reg, void, 100)) do
  245. if v.Name ~= "Base" then
  246. v:Destroy()
  247. end
  248. end
  249. a.CFrame = root.CFrame * CFrame.new(size / 2, size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  250. b.CFrame = root.CFrame * CFrame.new(-size / 2, size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  251. c.CFrame = root.CFrame * CFrame.new(0, size / 2, size / 2)
  252. d.CFrame = root.CFrame * CFrame.new(0, size / 2, -size / 2)
  253. a2.CFrame = root.CFrame * CFrame.new(size / 2, -size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  254. b2.CFrame = root.CFrame * CFrame.new(-size / 2, -size / 2, 0) * CFrame.Angles(0, math.rad(90), 0)
  255. c2.CFrame = root.CFrame * CFrame.new(0, -size / 2, size / 2)
  256. d2.CFrame = root.CFrame * CFrame.new(0, -size / 2, -size / 2)
  257. aa.CFrame = root.CFrame * CFrame.new(size / 2, 0, size / 2)
  258. bb.CFrame = root.CFrame * CFrame.new(-size / 2, 0, size / 2)
  259. cc.CFrame = root.CFrame * CFrame.new(-size / 2, 0, -size / 2)
  260. dd.CFrame = root.CFrame * CFrame.new(size / 2, 0, -size / 2)
  261. z.CFrame = root.CFrame * CFrame.new(size / 2, 0, 0) * CFrame.Angles(0, math.rad(90), 0)
  262. x.CFrame = root.CFrame * CFrame.new(-size / 2, 0, 0) * CFrame.Angles(0, math.rad(90), 0)
  263. c.CFrame = root.CFrame * CFrame.new(0, 0, size / 2) * CFrame.Angles(0, 0, math.rad(90))
  264. v.CFrame = root.CFrame * CFrame.new(0, 0, -size / 2) * CFrame.Angles(0, 0, math.rad(90))
  265. b.CFrame = root.CFrame * CFrame.new(0, size / 2, 0) * CFrame.Angles(math.rad(90), 0, 0)
  266. n.CFrame = root.CFrame * CFrame.new(0, -size / 2, 0) * CFrame.Angles(math.rad(90), 0, 0)
  267. end
  268. )
  269. end
  270. )
Add Comment
Please, Sign In to add comment