Advertisement
Idirina

C4 Bomb Script

Jan 21st, 2018
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.56 KB | None | 0 0
  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.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. --made by ur amigo slavedash
  99. --ur not supposed to be here anyways
  100.  
  101.  
  102. --Functions
  103.  
  104. local function WeldTogether(part1, part2, anchored)
  105. part1.Anchored = true
  106. local weld = Instance.new("Weld", part1)
  107. weld.Part0 = part1
  108. weld.Part1 = part2
  109. weld.C0 = CFrame.new()
  110. weld.C1 = part2.CFrame:toObjectSpace(part1.CFrame)
  111. weld.Parent = part1
  112. if anchored then
  113. part1.Anchored = true
  114. else
  115. part1.Anchored = false
  116. end
  117. end
  118.  
  119.  
  120. --Player
  121.  
  122. local plr = owner
  123. local mouse = Mouse
  124. repeat
  125. wait()
  126. until plr.Character
  127. local chr = plr.Character
  128.  
  129. local humanoid = chr:FindFirstChild("Humanoid")
  130. local root = chr:FindFirstChild("HumanoidRootPart")
  131.  
  132.  
  133. --Services
  134.  
  135. local debris = game:GetService("Debris")
  136. local userinputservice = game:GetService("UserInputService")
  137. local runservice = game:GetService("RunService")
  138.  
  139.  
  140. --Modes
  141.  
  142. local super_mode = false
  143. local omaemode = false
  144. local selfdestruct = false
  145. local invisible = false
  146.  
  147.  
  148. --Particles
  149.  
  150. local superfire = Instance.new("ParticleEmitter", root)
  151. superfire.Texture = "rbxassetid://248625108"
  152. superfire.Size = NumberSequence.new(5,0)
  153. superfire.Transparency = NumberSequence.new(0.8,1)
  154. superfire.LightEmission = 1
  155. superfire.ZOffset = 1
  156. superfire.Lifetime = NumberRange.new(1,1)
  157. superfire.Drag = -2
  158. superfire.Enabled = false
  159. superfire.Rate = 100
  160.  
  161.  
  162. --Sound
  163.  
  164. local supermusic = Instance.new("Sound", root)
  165. supermusic.SoundId = "rbxassetid://333361404"
  166. supermusic.Volume = 0.1
  167. supermusic.EmitterSize = 5
  168. supermusic.Looped = true
  169. supermusic.PlaybackSpeed = 1.2
  170.  
  171. local omaewa = Instance.new("Sound", root)
  172. omaewa.SoundId = "rbxassetid://157707359"
  173. omaewa.Volume = 0.5
  174. omaewa.EmitterSize = 5
  175. omaewa.PlaybackSpeed = 1.1
  176.  
  177.  
  178. --C4
  179.  
  180. local bombs = Instance.new("Model", chr)
  181. bombs.Name = "Bombs"
  182.  
  183. local explosions = Instance.new("Model", bombs)
  184. explosions.Name = "Explosions"
  185.  
  186. local C4s = Instance.new("Model", bombs)
  187. C4s.Name = "C4s"
  188.  
  189. local C4main = Instance.new("Part")
  190. C4main.Anchored = true
  191. C4main.CanCollide = true
  192. C4main.Size = Vector3.new()
  193. C4main.Material = Enum.Material.SmoothPlastic
  194. C4main.Transparency = 0
  195. C4main.BrickColor = BrickColor.new("Institutional white")
  196. C4main.Name = "C4"
  197.  
  198. local C4mesh = Instance.new("SpecialMesh", C4main)
  199. C4mesh.MeshType = "FileMesh"
  200. C4mesh.Scale = Vector3.new(1,1,1)
  201. C4mesh.MeshId = "rbxassetid://104516854"
  202. C4mesh.TextureId = "rbxassetid://104516981"
  203.  
  204.  
  205. --Place C4
  206.  
  207. local function PlaceC4(ceeframe)
  208. local C4clone = C4main:Clone()
  209. C4clone.Anchored = false
  210. C4clone.CFrame = ceeframe
  211. if invisible then
  212. C4clone.Transparency = 0.95
  213. end
  214. C4clone.Parent = C4s
  215. if mouse.Target then
  216. WeldTogether(C4clone, mouse.Target, false)
  217. end
  218. end
  219.  
  220. local function Spladow(blowupthing)
  221. coroutine.resume(coroutine.create(function()
  222. local explosion = Instance.new("Part", explosions)
  223. explosion.Name = "Explosion"
  224. explosion.Shape = "Ball"
  225. explosion.Material = Enum.Material.Neon
  226. explosion.BrickColor = BrickColor.new("Bright yellow")
  227. explosion.Anchored = true
  228. explosion.CanCollide = false
  229. explosion.Size = Vector3.new(1,1,1)
  230. explosion.CFrame = blowupthing.CFrame
  231.  
  232. local boomsound = Instance.new("Sound", explosion)
  233. boomsound.SoundId = "rbxassetid://365002938"
  234. boomsound.Volume = 1
  235. boomsound.EmitterSize = 5
  236. boomsound:Play()
  237.  
  238. coroutine.resume(coroutine.create(function()
  239. for i=1,3 do
  240. for i,v in pairs(game.Workspace:FindPartsInRegion3(Region3.new(explosion.Position - (explosion.Size/2), explosion.Position + (explosion.Size/2)), nil, math.huge)) do
  241. if not (v:IsDescendantOf(chr)) or selfdestruct then
  242. if not (v:IsDescendantOf(bombs)) then
  243. if (v.Name ~= "Base") and (v.Name ~= "Baseplate") then
  244. v.Anchored = false
  245. v:BreakJoints()
  246. v.Velocity = v.Velocity + ((v.Position - explosion.Position).unit * 50)
  247. if super_mode then
  248. v:Destroy()
  249. end
  250. end
  251. end
  252. end
  253. end
  254. explosion.Size = explosion.Size + Vector3.new(5,5,5)
  255. if super_mode then
  256. explosion.Size = explosion.Size * 1.1
  257. end
  258. explosion.Transparency = explosion.Transparency + (0.1 * 2)
  259. wait(0.05)
  260. end
  261. explosion.Transparency = 1
  262. wait(0.5)
  263. explosion:Destroy()
  264. boomsound:Destroy()
  265. end))
  266. blowupthing:Destroy()
  267. end))
  268. end
  269.  
  270. local function BlowUp()
  271. if #C4s:GetChildren() > 0 then
  272. if omaemode then
  273. omaewa:Play()
  274. repeat
  275. wait()
  276. until not omaewa.Playing
  277. omaewa:Stop()
  278. wait(0.2)
  279. for i,v in pairs(C4s:GetChildren()) do
  280. Spladow(v)
  281. end
  282. else
  283. for i,v in pairs(C4s:GetChildren()) do
  284. Spladow(v)
  285. if super_mode then
  286. wait(0.05)
  287. else
  288. wait(0.1)
  289. end
  290. end
  291. end
  292. end
  293. end
  294.  
  295.  
  296. --Controls
  297.  
  298. userinputservice.InputBegan:connect(function(input, gpe)
  299. if not gpe then
  300. if input.UserInputType == Enum.UserInputType.Keyboard then
  301. local key = input.KeyCode
  302.  
  303. --C4 Placing and Blowing Up
  304. if key == Enum.KeyCode.Q then
  305. PlaceC4(mouse.Hit)
  306. wait(0.1)
  307. if super_mode and userinputservice:IsKeyDown(Enum.KeyCode.Q) then
  308. repeat
  309. PlaceC4(mouse.Hit)
  310. wait()
  311. until not super_mode or not userinputservice:IsKeyDown(Enum.KeyCode.Q)
  312. end
  313. end
  314.  
  315. if key == Enum.KeyCode.E then
  316. BlowUp()
  317. end
  318.  
  319. --Modes
  320. if key == Enum.KeyCode.L then
  321. if super_mode then
  322. super_mode = false
  323. superfire.Enabled = false
  324. supermusic.Playing = false
  325. else
  326. super_mode = true
  327. superfire.Enabled = true
  328. supermusic.Playing = true
  329. end
  330. end
  331.  
  332. if key == Enum.KeyCode.K then
  333. if omaemode then
  334. omaemode = false
  335. else
  336. omaemode = true
  337. end
  338. end
  339.  
  340. if key == Enum.KeyCode.J then
  341. if selfdestruct then
  342. selfdestruct = false
  343. else
  344. selfdestruct = true
  345. end
  346. end
  347.  
  348. if key == Enum.KeyCode.H then
  349. if invisible then
  350. invisible = false
  351. else
  352. invisible = true
  353. end
  354. end
  355.  
  356. --Other
  357. if key == Enum.KeyCode.P then
  358. C4s:ClearAllChildren()
  359. explosions:ClearAllChildren()
  360. end
  361. end
  362. end
  363. end)
  364.  
  365.  
  366. --Health
  367.  
  368. runservice.Heartbeat:connect(function()
  369. humanoid.MaxHealth = math.huge
  370. humanoid.Health = math.huge
  371. humanoid.PlatformStand = false
  372. if not super_mode then
  373. humanoid.WalkSpeed = 16
  374. humanoid.JumpPower = 50
  375. elseif super_mode then
  376. humanoid.WalkSpeed = 32
  377. humanoid.JumpPower = 75
  378. end
  379. end)
  380.  
  381.  
  382. --control guide
  383.  
  384. print([["Controls:
  385. Q to place C4
  386. E to blow up C4s.
  387. P to clear all C4s and explosions
  388. L for super mode
  389. K for omae wa mou shindeiru
  390. J to enable the C4s to kill you
  391. H to make C4s invisible"]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement