Advertisement
The_God_M8

Rifle Body

May 10th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.82 KB | None | 0 0
  1. -- Location: Players.Cronizete.Character.BODYGUARDSV2
  2. -- Synapse Decompiler
  3. -- Purchase Here: https://brack4712.xyz/synapse/purchase
  4.  
  5. --// Controls
  6. --// X = Summon a bodyguard
  7. --// M = Change Types of bodyguards (Snipers, riflers) Sniper is the default
  8. --// Q = Aim
  9. --// C = Makes all the bodyguards disappear.
  10. --// Click = Shoot (You have to aim at somebody for snipers, you don't have to for the rifles)
  11. print("X is for Summon")
  12. print("M is for BodyGuard Change")
  13. print("Q for aim")
  14. print("C makes guard's vanish")
  15. print("Click to shoot")
  16. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  17. local Player,game,owner = owner,game
  18. local RealPlayer = Player
  19. do
  20. print("FE Compatibility code by Mokiros")
  21. local rp = RealPlayer
  22. script.Parent = rp.Character
  23.  
  24. --RemoteEvent for communicating
  25. local Event = Instance.new("RemoteEvent")
  26. Event.Name = "UserInput_Event"
  27.  
  28. --Fake event to make stuff like Mouse.KeyDown work
  29. local function fakeEvent()
  30. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  31. t.connect = t.Connect
  32. return t
  33. end
  34.  
  35. --Creating fake input objects with fake variables
  36. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  37. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  38. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  39. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  40. end}
  41. --Merged 2 functions into one by checking amount of arguments
  42. CAS.UnbindAction = CAS.BindAction
  43.  
  44. --This function will trigger the events that have been :Connect()'ed
  45. local function te(self,ev,...)
  46. local t = m[ev]
  47. if t and t._fakeEvent then
  48. for _,f in pairs(t.Functions) do
  49. f(...)
  50. end
  51. end
  52. end
  53. m.TrigEvent = te
  54. UIS.TrigEvent = te
  55.  
  56. Event.OnServerEvent:Connect(function(plr,io)
  57. if plr~=rp then return end
  58. m.Target = io.Target
  59. m.Hit = io.Hit
  60. if not io.isMouse then
  61. local b = io.UserInputState == Enum.UserInputState.Begin
  62. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  63. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[
  77. local Player = game:GetService("Players").LocalPlayer
  78. local Event = script:WaitForChild("UserInput_Event")
  79.  
  80. local Mouse = Player:GetMouse()
  81. local UIS = game:GetService("UserInputService")
  82. local input = function(io,a)
  83. if a then return end
  84. --Since InputObject is a client-side instance, we create and pass table instead
  85. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  86. end
  87. UIS.InputBegan:Connect(input)
  88. UIS.InputEnded:Connect(input)
  89.  
  90. local h,t
  91. --Give the server mouse data 30 times every second, but only if the values changed
  92. --If player is not moving their mouse, client won't fire events
  93. while wait(1/30) do
  94. if h~=Mouse.Hit or t~=Mouse.Target then
  95. h,t=Mouse.Hit,Mouse.Target
  96. Event:FireServer({isMouse=true,Target=t,Hit=h})
  97. end
  98. end]==],Player.Character)
  99.  
  100. ----Sandboxed game object that allows the usage of client-side methods and services
  101. --Real game object
  102. local _rg = game
  103.  
  104. --Metatable for fake service
  105. local fsmt = {
  106. __index = function(self,k)
  107. local s = rawget(self,"_RealService")
  108. if s then return s[k] end
  109. end,
  110. __newindex = function(self,k,v)
  111. local s = rawget(self,"_RealService")
  112. if s then s[k]=v end
  113. end,
  114. __call = function(self,...)
  115. local s = rawget(self,"_RealService")
  116. if s then return s(...) end
  117. end
  118. }
  119. local function FakeService(t,RealService)
  120. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  121. return setmetatable(t,fsmt)
  122. end
  123.  
  124. --Fake game object
  125. local g = {
  126. GetService = function(self,s)
  127. return self[s]
  128. end,
  129. Players = FakeService({
  130. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  131. },"Players"),
  132. UserInputService = FakeService(UIS,"UserInputService"),
  133. ContextActionService = FakeService(CAS,"ContextActionService"),
  134. }
  135. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  136. g.service = g.GetService
  137.  
  138. g.RunService = FakeService({
  139. RenderStepped = _rg:GetService("RunService").Heartbeat,
  140. BindToRenderStep = function(self,name,_,fun)
  141.  
  142. end,
  143. UnbindFromRenderStep = function(self,name)
  144. self._btrs[name]:Disconnect()
  145. end,
  146. },"RunService")
  147.  
  148. setmetatable(g,{
  149. __index=function(self,s)
  150. return _rg:GetService(s) or typeof(_rg[s])=="function"
  151. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  152. end,
  153. __newindex = fsmt.__newindex,
  154. __call = fsmt.__call
  155. })
  156. --Changing owner to fake player object to support owner:GetMouse()
  157. game,owner = g,g.Players.LocalPlayer
  158. end
  159.  
  160. plr = owner
  161. char = owner.Character
  162.  
  163. --// Anti double
  164. script.Name = "BODYGUARDSV2_TEMP"
  165. for _, a in pairs(char:GetDescendants()) do
  166. if a.Name == "BODYGUARDSV2" then
  167. a:Destroy()
  168. elseif a.Name == "" then
  169. a:Destroy()
  170. end
  171. end
  172. script.Name = "BODYGUARDSV2"
  173. --// Main Script
  174.  
  175. head = char.Head
  176. mouse = owner:GetMouse()
  177. sam = 0
  178. char.Archivable = true
  179. arms = nil
  180. torso = nil
  181. follow = false
  182. current = nil
  183. curfollow = nil
  184. rifleshoot = false
  185. targ, huma = nil,nil
  186.  
  187. --// points
  188. point1 = Instance.new('Part', char)
  189. point1.Anchored = false
  190. point1.CanCollide = false
  191. point1.Transparency = 1
  192. point1.Size = Vector3.new(0.2,0.2,0.2)
  193.  
  194. Weld = Instance.new("Weld",owner.Character)
  195. Weld.Part0 = owner.Character["Torso"]
  196. Weld.Part1 = point1
  197. Weld.C1 = CFrame.new(10, 0, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
  198.  
  199. point3 = Instance.new('Part', char)
  200. point3.Anchored = false
  201. point3.CanCollide = false
  202. point3.Transparency = 1
  203. point3.Size = Vector3.new(0.2,0.2,0.2)
  204.  
  205. Weld = Instance.new("Weld",owner.Character)
  206. Weld.Part0 = owner.Character["Torso"]
  207. Weld.Part1 = point3
  208. Weld.C1 = CFrame.new(-10, 0, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
  209.  
  210. point2 = Instance.new('Part', char)
  211. point2.Anchored = false
  212. point2.CanCollide = false
  213. point2.Transparency = 1
  214. point2.Size = Vector3.new(0.2,0.2,0.2)
  215.  
  216. Weld = Instance.new("Weld",owner.Character)
  217. Weld.Part0 = owner.Character["Torso"]
  218. Weld.Part1 = point2
  219. Weld.C1 = CFrame.new(20, 0, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
  220.  
  221. point4 = Instance.new('Part', char)
  222. point4.Anchored = false
  223. point4.CanCollide = false
  224. point4.Transparency = 1
  225. point4.Size = Vector3.new(0.2,0.2,0.2)
  226.  
  227. Weld = Instance.new("Weld",owner.Character)
  228. Weld.Part0 = owner.Character["Torso"]
  229. Weld.Part1 = point4
  230. Weld.C1 = CFrame.new(-20, 0, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
  231.  
  232.  
  233.  
  234.  
  235. --// points
  236.  
  237. --// Configuration
  238.  
  239. max = 15
  240. max1 = 15
  241. maxammo = 30
  242. mode = "Snipers"
  243.  
  244. --//
  245.  
  246. snipers,riflers,welds = {},{},{}
  247.  
  248. skinc = {
  249. 'Rust',
  250. 'Cool yellow',
  251. 'Br. yellowish orange',
  252. 'Pastel yellow',
  253. 'CGA brown'
  254. }
  255.  
  256. props = {
  257. 'HeadColor',
  258. 'LeftArmColor',
  259. 'RightArmColor',
  260. 'TorsoColor',
  261. 'RightLegColor',
  262. 'LeftLegColor'
  263. }
  264.  
  265. snpr = char:Clone()
  266. snpr.Name = ""
  267.  
  268. for _, a in pairs(snpr:children()) do
  269. if a:IsA'CharacterMesh' or a:IsA'Accessory' or a:IsA'Shirt' or a:IsA'Pants' then
  270. a:Destroy()
  271. end
  272. end
  273.  
  274. snpr.Parent = nil
  275.  
  276. bg = Instance.new("BodyGyro", snpr.HumanoidRootPart)
  277. bg.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  278. bg.Name = "FOLLOW"
  279. bg.P = 10000
  280. bg.D = 100
  281.  
  282. sfx = Instance.new('Sound', snpr.Head)
  283. sfx.SoundId = "rbxassetid://740599871"
  284. sfx.Volume = 3
  285. sfx2 = Instance.new('Sound', snpr)
  286. sfx2.Name = "SNIPERSOUND"
  287. sfx2.SoundId = "rbxassetid://136523485"
  288. sfx2.Volume = 3
  289.  
  290. lazor = Instance.new('Part', snpr)
  291. lazor.Name = "Laser"
  292. lazor.Anchored = true
  293. lazor.Shape = Enum.PartType.Ball
  294. lazor.Size = Vector3.new(0.3,0.3,0.3)
  295. lazor.BrickColor = BrickColor.new('Really red')
  296. lazor.Transparency = 0.4
  297. lazor.CanCollide = false
  298.  
  299. shirt = Instance.new('Shirt', snpr)
  300. shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=139465409"
  301. pants = Instance.new('Pants', snpr)
  302. pants.PantsTemplate = "http://www.roblox.com/asset/?id=139466214"
  303. ----------------------------------------------------------------
  304. hat = Instance.new('Part', snpr)
  305. hat.Name = 'Hat'
  306. hat.Anchored = false
  307. hat.CanCollide = false
  308. mesh = Instance.new('SpecialMesh', hat)
  309. mesh.MeshId = "http://www.roblox.com/asset/?id=31152467"
  310. mesh.TextureId = "http://www.roblox.com/asset/?id=32002857"
  311. mesh.Scale = Vector3.new(1,1,1)
  312. weld = Instance.new('Weld', hat)
  313. weld.Part0 = hat
  314. weld.Part1 = snpr.Head
  315. weld.C0 = CFrame.new(0,-0.2,0)
  316. --------------------------------------------
  317. sniper = Instance.new('Part', snpr)
  318. sniper.Anchored = false
  319. sniper.CanCollide = false
  320. sniper.Name = "Sniper"
  321. sniper.Size = Vector3.new(7.88, 1.77, 1)
  322. mesh = Instance.new('SpecialMesh', sniper)
  323. mesh.MeshId = "rbxassetid://462309398"
  324. mesh.TextureId = "rbxassetid://462309404"
  325. mesh.Scale = Vector3.new(0.006, 0.006, 0.006)
  326. weld = Instance.new('Weld', sniper)
  327. weld.Part0 = sniper
  328. weld.Part1 = snpr.Head
  329. weld.C0 = CFrame.new(-2,0.5,-0.2) * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))
  330.  
  331. arms = {snpr:FindFirstChild("Left Arm"), snpr:FindFirstChild("Right Arm")}
  332. torso = snpr:FindFirstChild("Torso")
  333.  
  334. if arms ~= nil and torso ~= nil then
  335. local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
  336. if sh ~= nil then
  337. local yes = true
  338. if yes then
  339. yes = false
  340. sh[1].Part1 = nil
  341. sh[2].Part1 = nil
  342. local weld1 = Instance.new("Weld")
  343. weld1.Part0 = torso
  344. weld1.Parent = torso
  345. weld1.Part1 = arms[1]
  346. weld1.C1 = CFrame.new(-0.249, 1.35, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
  347. welds[1] = weld1
  348. local weld2 = Instance.new("Weld")
  349. weld2.Part0 = torso
  350. weld2.Parent = torso
  351. weld2.Part1 = arms[2]
  352. weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
  353. welds[2] = weld2
  354. end
  355. end
  356. end
  357.  
  358. function sniper(pos)
  359. if sam <= max - 1 then
  360. local sniper = snpr:Clone()
  361. local bodyc = sniper:FindFirstChildOfClass'BodyColors'
  362. local skincolor = skinc[math.random(1,5)]
  363.  
  364. for _, a in pairs(props) do
  365. bodyc[a] = BrickColor.new(skincolor)
  366. end
  367.  
  368. sniper.Parent = char
  369. sniper:MoveTo(pos)
  370. sniper.Torso.CFrame = CFrame.new(sniper.Torso.Position, head.Position)
  371. table.insert(snipers, sniper)
  372. sam = sam + 1
  373. end
  374. end
  375.  
  376. function rifler(pos)
  377. if sam <= max1 - 1 then
  378. local rifler = snpr:Clone()
  379. local bodyc = rifler:FindFirstChildOfClass'BodyColors'
  380. local skincolor = skinc[math.random(1,5)]
  381.  
  382. for _, a in pairs(props) do
  383. bodyc[a] = BrickColor.new(skincolor)
  384. end
  385.  
  386. for _, a in pairs(rifler:GetDescendants()) do
  387. if a:IsA'BodyGyro' then
  388. a:Destroy()
  389. end
  390. end
  391.  
  392. rifler.Parent = char
  393. rifler:MoveTo(pos)
  394. rifler.Torso.CFrame = CFrame.new(rifler.Torso.Position, head.Position)
  395. rifler:FindFirstChild'SNIPERSOUND'.Pitch = 1.2
  396. rifle = rifler:FindFirstChild'Sniper'
  397. rifle.Name = "Rifle"
  398. rifle:FindFirstChildOfClass'SpecialMesh'.TextureId = "rbxassetid://546505949"
  399. rifle:FindFirstChildOfClass'SpecialMesh'.MeshId = "rbxassetid://546505802"
  400. rifle:FindFirstChildOfClass'SpecialMesh'.Scale = Vector3.new(0.2, 0.2, 0.2)
  401. rifle:FindFirstChildOfClass'Weld'.C0 = CFrame.new(-.4,.6,1.6) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))
  402. table.insert(riflers, rifler)
  403. sam = sam + 1
  404. end
  405. end
  406.  
  407. function ray(a,b)
  408. local ray = Ray.new(a.CFrame.p, (b - a.CFrame.p).unit * 700)
  409. local part, position = workspace:FindPartOnRay(ray, char, false, true)
  410.  
  411. local beam = Instance.new("Part", workspace)
  412. beam.FormFactor = "Custom"
  413. beam.Material = "Plastic"
  414. beam.Transparency = 0.25
  415. beam.Anchored = true
  416. beam.Locked = true
  417. beam.CanCollide = false
  418. beam.BrickColor = BrickColor.new('Really black')
  419.  
  420. local distance = (a.CFrame.p - position).magnitude
  421. beam.Size = Vector3.new(0.08, 0.08, distance)
  422. beam.CFrame = CFrame.new(a.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
  423.  
  424. game:GetService('Debris'):AddItem(beam, 0.1)
  425. end
  426.  
  427. mouse.KeyDown:connect(function(k)
  428. local key = k:lower()
  429. if key == "x" then
  430. follow = false
  431. if mode == "Snipers" then
  432. sniper(mouse.Hit.p)
  433. elseif mode == "Riflers" then
  434. rifler(mouse.Hit.p)
  435. end
  436. wait(.3)
  437. if curfollow then
  438. follow = true
  439. elseif not curfollow then
  440. follow = false
  441. end
  442. elseif key == "c" then
  443. for _, a in pairs(char:children()) do
  444. if a.Name == "" then
  445. for i = 1,10 do
  446. a:FindFirstChild'HumanoidRootPart'.CFrame = a:FindFirstChild'HumanoidRootPart'.CFrame * CFrame.new(0,-i + 0.8,0)
  447. wait()
  448. end
  449. wait(.15)
  450. a:Destroy()
  451. sam = sam - 1
  452. end
  453. end
  454. elseif key == "m" then
  455. if mode == "Snipers" then
  456. mode = "Riflers"
  457. elseif mode == "Riflers" then
  458. mode = "Snipers"
  459. end
  460. elseif key == "q" then
  461. if not follow then
  462. follow = true
  463. curfollow = true
  464. on = false
  465. for i = 1, sam / 2 do
  466. wait(.6)
  467. local now
  468. ypcall(function()
  469. if mode == "Snipers" then
  470. now = snipers[math.random(1,#snipers)]
  471. elseif mode == "Riflers" then
  472. now = riflers[math.random(1,#riflers)]
  473. end
  474. end)
  475. for _, a in pairs(riflers) do
  476. bg = Instance.new("BodyGyro", a.HumanoidRootPart)
  477. bg.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  478. bg.Name = "FOLLOW"
  479. bg.P = 10000
  480. bg.D = 100
  481. end
  482. now.Head.Sound:Resume()
  483. current = now.Head.Sound.SoundId
  484. end
  485. elseif follow then
  486. for _, a in pairs(riflers) do
  487. for _, b in pairs(a:GetDescendants()) do
  488. if b:IsA'BodyGyro' then
  489. b:Destroy()
  490. end
  491. end
  492. end
  493. follow = false
  494. curfollow = false
  495. end
  496. end
  497. end)
  498.  
  499. mouse.Button1Down:connect(function()
  500. if follow and mode ~= "Riflers" and mouse.Target and mouse.Target.Parent and mouse.Target.Parent:FindFirstChildOfClass'Humanoid' then
  501. follow = false
  502. local targ = mouse.Target
  503. huma = targ.Parent:FindFirstChildOfClass'Humanoid'
  504. for _, a in pairs(targ.Parent:children()) do
  505. if a:IsA'ForceField' then
  506. a:Destroy()
  507. end
  508. end
  509. huma.MaxHealth = 100
  510. huma.Name = "Humanoid"
  511. if mode == "Snipers" then
  512. for _, a in pairs(snipers) do
  513. if a:FindFirstChild'HumanoidRootPart' then
  514. wait(.2)
  515. rootpart = a.HumanoidRootPart
  516. snd = rootpart.Parent:FindFirstChild'SNIPERSOUND'
  517. snd:Play()
  518. ray(a:FindFirstChild'Sniper',targ.Parent.Head.Position)
  519. huma:TakeDamage(huma.MaxHealth/2/2/2)
  520. end
  521. end
  522. follow = true
  523. end
  524. end
  525. end)
  526.  
  527. mouse.Button1Down:connect(function()
  528. if mode == "Riflers" then
  529. rifleshoot = true
  530. end
  531. end)
  532.  
  533. mouse.Button1Up:connect(function()
  534. if mode == "Riflers" then
  535. rifleshoot = false
  536. end
  537. end)
  538.  
  539. while wait() do
  540. ypcall(function()
  541. riflers[1]:FindFirstChildOfClass'Humanoid':MoveTo(point1.Position)
  542. riflers[2]:FindFirstChildOfClass'Humanoid':MoveTo(point2.Position)
  543. riflers[3]:FindFirstChildOfClass'Humanoid':MoveTo(point3.Position)
  544. riflers[4]:FindFirstChildOfClass'Humanoid':MoveTo(point4.Position)
  545. end)
  546. if follow then
  547. if mode == "Snipers" then
  548. for _, a in pairs(snipers) do
  549. if a:FindFirstChild'HumanoidRootPart' then
  550. rootpart = a.HumanoidRootPart
  551. rootpart.FOLLOW.CFrame = CFrame.new(rootpart.Position, mouse.Hit.p * Vector3.new(1,0,1) + rootpart.Position * Vector3.new(0,1,0))
  552. rootpart.Parent:WaitForChild'Laser'.CFrame = mouse.Hit
  553. end
  554. end
  555. elseif mode == "Riflers" then
  556. for _, a in pairs(riflers) do
  557. if a:FindFirstChild'HumanoidRootPart' then
  558. rootpart = a.HumanoidRootPart
  559. ypcall(function() rootpart.FOLLOW.CFrame = CFrame.new(rootpart.Position, mouse.Hit.p * Vector3.new(1,0,1) + rootpart.Position * Vector3.new(0,1,0)) end)
  560. rootpart.Parent:WaitForChild'Laser'.CFrame = mouse.Hit
  561. end
  562. end
  563. end
  564. end
  565. if rifleshoot and follow and mouse.Target and mouse.Target.Parent then
  566. local targ = mouse.Target
  567. local huma = nil
  568. if targ.Parent:FindFirstChildOfClass'Humanoid' then
  569. huma = targ.Parent:FindFirstChildOfClass'Humanoid'
  570. else
  571. huma = nil
  572. end
  573. if huma ~= nil then
  574. for _, a in pairs(riflers) do
  575. if a:FindFirstChild'HumanoidRootPart' and huma.Health ~= 0 then
  576. wait(.02)
  577. rootpart = a.HumanoidRootPart
  578. snd = rootpart.Parent:FindFirstChild'SNIPERSOUND'
  579. snd.Pitch = 80
  580. snd:Resume()
  581. ray(a:FindFirstChild'Rifle',targ.Parent.Torso.Position)
  582. huma:TakeDamage(huma.MaxHealth/40/25/60/30/99)
  583. end
  584. end
  585. else
  586. for _, a in pairs(riflers) do
  587. snd = rootpart.Parent:FindFirstChild'SNIPERSOUND'
  588. snd.Pitch = 80
  589. snd:Resume()
  590. ray(a:FindFirstChild'Rifle',mouse.Hit.p)
  591. end
  592. end
  593. end
  594. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement