Advertisement
memberhero

xGun SB

Apr 11th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.63 KB | None | 0 0
  1. --MADE BY OneLegend (NOT THE SCRIPT) Thanks to TheRedAngel for letting me add. Feel free to take his model too. http://www.roblox.com/TheRedAngels-SB-Gift-NEW-SCRIPTS-item?id=88063410
  2. --LOCAL SCRIPT: Go to line 4 and put your name where it says "YOUR NAME HERE"
  3.  
  4. Name = "basstracker1970"
  5. Colors = {"Cyan", "Black"}
  6. Plrs = game:GetService("Players")
  7.  
  8. me = Plrs[Name]
  9. char = me.Character
  10. Modelname = "xGun"
  11. Toolname = "xGun"
  12. Surfaces = {"FrontSurface", "BackSurface", "TopSurface", "BottomSurface", "LeftSurface", "RightSurface"}
  13. necko = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  14. selected = false
  15. Hurt = false
  16. Deb = true
  17. Able = true
  18. Prop = {Damage = 30}
  19.  
  20. ToolIcon = ""
  21. MouseIc = ""
  22. MouseDo = ""
  23.  
  24. Add = {
  25. Sphere = function(P)
  26. local m = Instance.new("SpecialMesh",P)
  27. m.MeshType = "Sphere"
  28. return m
  29. end,
  30. BF = function(P)
  31. local bf = Instance.new("BodyForce",P)
  32. bf.force = Vector3.new(0, P:GetMass()*147, 0)
  33. return bf
  34. end,
  35. BP = function(P)
  36. local bp = Instance.new("BodyPosition",P)
  37. bp.maxForce = Vector3.new(math.huge, 0, math.huge)
  38. bp.P = 14000
  39. return bp
  40. end,
  41. BG = function(P)
  42. local bg = Instance.new("BodyGyro",P)
  43. bg.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  44. bg.P = 14000
  45. return bg
  46. end,
  47. Mesh = function(P, ID, x, y, z)
  48. local m = Instance.new("SpecialMesh")
  49. m.MeshId = ID
  50. m.Scale = Vector3.new(x, y, z)
  51. m.Parent = P
  52. return m
  53. end,
  54. Sound = function(P, ID, vol, pitch)
  55. local s = Instance.new("Sound")
  56. s.SoundId = ID
  57. s.Volume = vol
  58. s.Pitch = pitch
  59. s.Parent = P
  60. return s
  61. end
  62. }
  63.  
  64. function find(tab, arg)
  65. local ah = nil
  66. for i,v in pairs(tab) do
  67. if v == arg then
  68. ah = v
  69. end
  70. end
  71. return ah
  72. end
  73.  
  74. function getAllParts(from)
  75. local t = {}
  76. function getParts(where)
  77. for i, v in pairs(where:children()) do
  78. if v:IsA("BasePart") then
  79. if v.Parent ~= char and v.Parent.Parent ~= char then
  80. table.insert(t, v)
  81. end
  82. end
  83. getParts(v)
  84. end
  85. end
  86. getParts(workspace)
  87. return t
  88. end
  89.  
  90. function RayCast(pos1, pos2, maxDist, forward)
  91. local list = getAllParts(workspace)
  92. local pos0 = pos1
  93. for dist = 1, maxDist, forward do
  94. pos0 = (CFrame.new(pos1, pos2) * CFrame.new(0, 0, -dist)).p
  95. for _, v in pairs(list) do
  96. local pos3 = v.CFrame:pointToObjectSpace(pos0)
  97. local s = v.Size
  98. if pos3.x > -(s.x/2) and pos3.x < (s.x/2) and pos3.y > -(s.y/2) and pos3.y < (s.y/2) and pos3.z > -(s.z/2) and pos3.x < (s.z/2) and v.CanCollide == true then
  99. return pos0, v
  100. end
  101. end
  102. end
  103. return pos0, nil
  104. end
  105.  
  106. function Part(Parent, Anchor, Collide, Tran, Ref, Color, X, Y, Z, Break)
  107. local p = Instance.new("Part")
  108. p.formFactor = "Custom"
  109. p.Anchored = Anchor
  110. p.CanCollide = Collide
  111. p.Transparency = Tran
  112. p.Reflectance = Ref
  113. p.BrickColor = BrickColor.new(Color)
  114. for _, Surf in pairs(Surfaces) do
  115. p[Surf] = "Smooth"
  116. end
  117. p.Size = Vector3.new(X, Y, Z)
  118. if Break then
  119. p:BreakJoints()
  120. else p:MakeJoints() end
  121. p.Parent = Parent
  122. return p
  123. end
  124.  
  125. function Weld(p0, p1, x, y, z, a, b, c)
  126. local w = Instance.new("Weld")
  127. w.Parent = p0
  128. w.Part0 = p0
  129. w.Part1 = p1
  130. w.C1 = CFrame.new(x,y,z) * CFrame.Angles(a,b,c)
  131. return w
  132. end
  133.  
  134. function ComputePos(pos1, pos2)
  135. local pos3 = Vector3.new(pos2.x, pos1.y, pos2.z)
  136. return CFrame.new(pos1, pos3)
  137. end
  138.  
  139. function getHumanoid(c)
  140. local h = nil
  141. for i,v in pairs(c:children()) do
  142. if v:IsA("Humanoid") and c ~= char then
  143. if v.Health > 0 then
  144. h = v
  145. end
  146. end
  147. end
  148. return h
  149. end
  150.  
  151. for i,v in pairs(char:children()) do
  152. if v.Name == Modelname then
  153. v:remove()
  154. end
  155. end
  156.  
  157. torso = char.Torso
  158. neck = torso.Neck
  159. hum = char.Humanoid
  160. Rarm = char["Right Arm"]
  161. Larm = char["Left Arm"]
  162. Rleg = char["Right Leg"]
  163. Lleg = char["Left Leg"]
  164.  
  165. hc = Instance.new("Humanoid")
  166. hc.Health = 0
  167. hc.MaxHealth = 0
  168.  
  169. slash = Add.Sound(nil, "rbxasset://sounds//swordslash.wav", 0.9, 0.8)
  170. hitsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2801263", 0.7, 0.6)
  171. charge = Add.Sound(nil, "http://www.roblox.com/asset/?id=2101137", 0.8, 0.65)
  172. boom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2691586", 0.8, 0.3)
  173. smashsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2692806", 0.8, 0.35)
  174. boomboom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2760979", 1, 0.18)
  175.  
  176. function PlaySound(sound, pitch, vol)
  177. local s = sound:clone()
  178. if pitch ~= nil then
  179. if tonumber(pitch) then
  180. s.Pitch = tonumber(pitch)
  181. end
  182. end
  183. if vol ~= nil then
  184. if tonumber(vol) then
  185. s.Volume = tonumber(vol)
  186. end
  187. end
  188. s.Parent = torso
  189. s.PlayOnRemove = true
  190. coroutine.resume(coroutine.create(function()
  191. wait()
  192. s:remove()
  193. end))
  194. end
  195.  
  196. Mo = Instance.new("Model")
  197. Mo.Name = Modelname
  198.  
  199. RABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  200. LABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  201. RLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  202. LLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  203.  
  204. RABW = Weld(torso, RABrick, -1.5, -0.5, 0, 0, 0, 0)
  205. LABW = Weld(torso, LABrick, 1.5, -0.5, 0, 0, 0, 0)
  206. RLBW = Weld(torso, RLBrick, -0.5, 1.2, 0, 0, 0, 0)
  207. LLBW = Weld(torso, LLBrick, 0.5, 1.2, 0, 0, 0, 0)
  208.  
  209. RAW = Weld(RABrick, nil, 0, 0.5, 0, 0, 0, 0)
  210. LAW = Weld(LABrick, nil, 0, 0.5, 0, 0, 0, 0)
  211. RLW = Weld(RLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  212. LLW = Weld(LLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  213.  
  214. HB = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  215. HBW = Weld(Rarm, HB, 0, 1, 0, 0, 0, 0)
  216. HW = Weld(HB, nil, 0, -0.2, 0, math.pi/2, 0, 0)
  217.  
  218. TH = Weld(torso, nil, -0.3, -0.25, 1.5, math.rad(-60), 0, math.rad(-45))
  219. THMain = TH.C1
  220.  
  221. BG = Add.BG(nil)
  222.  
  223. RAWStand, LAWStand, RLWStand, LLWStand, HWStand, NeckStand = nil
  224.  
  225. handle = Part(Mo, false, false, 0, 0, Colors[2], 0.6, 1.6, 0.6, true)
  226. Instance.new("SpecialMesh",handle)
  227. handle.Name = "Handle"
  228.  
  229. tip1 = Part(Mo, false, false, 0, 0, Colors[2], 1, 0.8, 1, true)
  230. Instance.new("SpecialMesh",tip1)
  231. Weld(handle, tip1, 0, -0.1, 1, math.rad(-90), 0, 0)
  232.  
  233. tip2 = Part(Mo, false, false, 0, 0, Colors[2], 0.6, 0.8, 0.6, true)
  234. Instance.new("SpecialMesh",tip2)
  235. Weld(tip1, tip2, 0, -0.4, 0, 0, 0, 0)
  236.  
  237. tip3 = Part(Mo, false, false, 0, 0, Colors[2], 1.2, 0.3, 1.2, true)
  238. Instance.new("CylinderMesh",tip3)
  239. Weld(tip2, tip3, 0, -0.3, 0, 0, 0, 0)
  240.  
  241. for i = 0, 360, 22.5 do
  242. local tip4 = Part(Mo, false, false, 0, 0, Colors[1], 0.2, 1, 0.2, true)
  243. Instance.new("BlockMesh",tip4).Scale = Vector3.new(1, 1, 0.9)
  244. local w = Weld(tip3, tip4, -0.35, 0, 0, 0, 0, 0)
  245. w.C0 = CFrame.new(0, 0.65, 0) * CFrame.Angles(0, math.rad(i), 0)
  246. local tip5 = Part(Mo, false, false, 0, 0, Colors[2], 0.35, 0.2, 0.25, true)
  247. Instance.new("BlockMesh",tip5)
  248. local w2 = Weld(tip4, tip5, -0.05, -0.6, 0, 0, 0, 0)
  249. local tip7 = Part(Mo, false, false, 0, 0, Colors[2], 0.2, 0.4, 0.2, true)
  250. Instance.new("BlockMesh",tip7).Scale = Vector3.new(1, 1, 1)
  251. Weld(tip5, tip7, 0.1, -0.3, 0, 0, 0, 0)
  252. local tip8 = Part(Mo, false, false, 0, 0, Colors[2], 0.35, 0.2, 0.25, true)
  253. Instance.new("BlockMesh",tip8)
  254. Weld(tip5, tip8, 0, -0.5, 0, 0, 0, 0)
  255. end
  256.  
  257. for i = 0, 360, 90 do
  258. local tip6 = Part(Mo, false, false, 0, 0, Colors[2], 0.2, 1, 0.2, true)
  259. Instance.new("BlockMesh",tip6)
  260. local w = Weld(tip3, tip6, -0.45, 0, 0, 0, 0, 0)
  261. w.C0 = CFrame.new(0, 0.65, 0) * CFrame.Angles(0, math.rad(i), 0)
  262. end
  263.  
  264.  
  265. Mo.Parent = char
  266. TH.Part1 = handle
  267.  
  268. if script.Parent.className ~= "HopperBin" then
  269. h = Instance.new("HopperBin",me.Backpack)
  270. h.Name = Toolname
  271. h.TextureId = ToolIcon
  272. script.Parent = h
  273. end
  274.  
  275. bin = script.Parent
  276.  
  277. function detach(bool)
  278. LLW.C0 = CFrame.new(0, 0, 0)
  279. RLW.C0 = CFrame.new(0, 0, 0)
  280. LAW.C0 = CFrame.new(0, 0, 0)
  281. RAW.C0 = CFrame.new(0, 0, 0)
  282. if bool then
  283. LLW.Part1 = nil
  284. RLW.Part1 = nil
  285. RAW.Part1 = nil
  286. LAW.Part1 = nil
  287. TH.Part1 = handle
  288. HW.Part1 = nil
  289. end
  290. end
  291.  
  292. function attach()
  293. RAW.Part1 = Rarm
  294. LAW.Part1 = Larm
  295. RLW.Part1 = Rleg
  296. LLW.Part1 = Lleg
  297. end
  298.  
  299. function normal()
  300. neck.C0 = NeckStand
  301. RAW.C0 = RAWStand
  302. LAW.C0 = LAWStand
  303. RLW.C0 = RLWStand
  304. LLW.C0 = LLWStand
  305. RAW.C1 = CFrame.new(0, 0.5, 0)
  306. LAW.C1 = CFrame.new(0, 0.5, 0)
  307. RLW.C1 = CFrame.new(0, 0.8, 0)
  308. LLW.C1 = CFrame.new(0, 0.8, 0)
  309. HW.C0 = HWStand
  310. end
  311.  
  312. function idleanim()
  313. attach()
  314. for i = 0, 1, 0.03 do
  315. RAW.C0 = RAWStand * CFrame.Angles(0, 0, 0)
  316. LAW.C0 = LAWStand * CFrame.Angles(0, 0, 0)
  317. RLW.C0 = RLWStand * CFrame.Angles(0, 0, 0)
  318. LLW.C0 = LLWStand * CFrame.Angles(0, 0, 0)
  319. neck.C0 = NeckStand * CFrame.Angles(0, 0, 0)
  320. if selected == false or torso.Velocity.magnitude > 2 or Able == false then break end
  321. wait()
  322. end
  323. wait()
  324. for i = 1, 0, -0.02 do
  325. RAW.C0 = RAWStand * CFrame.Angles(0, 0, 0)
  326. LAW.C0 = LAWStand * CFrame.Angles(0, 0, 0)
  327. RLW.C0 = RLWStand * CFrame.Angles(0, 0, 0)
  328. LLW.C0 = LLWStand * CFrame.Angles(0, 0, 0)
  329. neck.C0 = NeckStand * CFrame.Angles(0, 0, 0)
  330. if selected == false or torso.Velocity.magnitude > 2 or Able == false then break end
  331. wait()
  332. end
  333. normal()
  334. end
  335.  
  336. function runanim()
  337. RLW.Part1 = nil
  338. LLW.Part1 = nil
  339. end
  340.  
  341. --[[coroutine.resume(coroutine.create(function()
  342. while true do
  343. wait()
  344. if selected and Able == true then
  345. if torso.Velocity.magnitude < 2 then
  346. idleanim()
  347. wait()
  348. else
  349. runanim()
  350. wait()
  351. end
  352. end
  353. end
  354. end))]]
  355.  
  356. function selectanim()
  357. RAW.Part1 = Rarm
  358. for i = 0, 1, 0.14 do
  359. RAW.C0 = CFrame.Angles(math.rad(100*i), math.rad(-10*i), math.rad(-70*i)) * CFrame.new(0.6*i, -1*i, 0)
  360. neck.C0 = necko * CFrame.Angles(math.rad(-25*i), 0, math.rad(30*i))
  361. wait()
  362. end
  363. HW.C0 = CFrame.Angles(0, math.rad(70), math.rad(40)) * CFrame.new(0, 0, -0.8)
  364. HW.Part1 = handle
  365. TH.Part1 = nil
  366. LAW.Part1 = Larm
  367. for i = 0, 1, 0.14 do
  368. RAW.C0 = CFrame.Angles(math.rad(100), math.rad(-10-15*i), math.rad(-70+60*i)) * CFrame.new(0.6-0.6*i, -1+1*i, 0)
  369. LAW.C0 = CFrame.Angles(math.rad(35*i), math.rad(20*i), math.rad(-25*i))
  370. neck.C0 = necko * CFrame.Angles(math.rad(-25+5*i), 0, math.rad(30-55*i))
  371. HW.C0 = CFrame.Angles(0, math.rad(70-70*i), math.rad(40+80*i)) * CFrame.new(0, 0, -0.8+0.6*i)
  372. wait()
  373. end
  374. for i = 0, 1, 0.1 do
  375. RAW.C0 = CFrame.Angles(math.rad(100-10*i), math.rad(-10-15+25*i), math.rad(-10+55*i)) * CFrame.new(-0.8*i, 0, 0.05*i)
  376. LAW.C0 = CFrame.Angles(math.rad(35+55*i), math.rad(20-20*i), math.rad(-25+90*i)) * CFrame.new(-0.3*i, -1.2*i, 0)
  377. neck.C0 = necko * CFrame.Angles(math.rad(-20+20*i), 0, math.rad(30-55-20*i))
  378. HW.C0 = CFrame.Angles(0, 0, math.rad(120+60*i)) * CFrame.new(0, 0, -0.2+0.6*i)
  379. wait()
  380. end
  381. if RAWStand == nil then
  382. RAWStand = RAW.C0
  383. LAWStand = LAW.C0
  384. RLWStand = RLW.C0
  385. LLWStand = LLW.C0
  386. HWStand = HW.C0
  387. NeckStand = neck.C0
  388. end
  389. BG.Parent = torso
  390. end
  391.  
  392. function deselanim()
  393. BG.Parent = nil
  394. for i = 1, 0, -0.1 do
  395. RAW.C0 = CFrame.Angles(math.rad(100-10*i), math.rad(-10-15+25*i), math.rad(-10+55*i)) * CFrame.new(-0.8*i, 0, 0.05*i)
  396. LAW.C0 = CFrame.Angles(math.rad(35+55*i), math.rad(20-20*i), math.rad(-25+90*i)) * CFrame.new(-0.3*i, -1.2*i, 0)
  397. neck.C0 = necko * CFrame.Angles(math.rad(-20+20*i), 0, math.rad(30-55-20*i))
  398. HW.C0 = CFrame.Angles(0, 0, math.rad(120+60*i)) * CFrame.new(0, 0, -0.2+0.6*i)
  399. wait()
  400. end
  401. for i = 1, 0, -0.14 do
  402. RAW.C0 = CFrame.Angles(math.rad(100), math.rad(-10-15*i), math.rad(-70+60*i)) * CFrame.new(0.6-0.6*i, -1+1*i, 0)
  403. LAW.C0 = CFrame.Angles(math.rad(35*i), math.rad(20*i), math.rad(-25*i))
  404. neck.C0 = necko * CFrame.Angles(math.rad(-25+5*i), 0, math.rad(30-55*i))
  405. HW.C0 = CFrame.Angles(0, math.rad(70-70*i), math.rad(40+80*i)) * CFrame.new(0, 0, -0.8+0.6*i)
  406. wait()
  407. end
  408. HW.Part1 = nil
  409. LAW.Part1 = nil
  410. TH.Part1 = handle
  411. for i = 1, 0, -0.14 do
  412. RAW.C0 = CFrame.Angles(math.rad(100*i), math.rad(-10*i), math.rad(-70*i)) * CFrame.new(0.6*i, -1*i, 0)
  413. neck.C0 = necko * CFrame.Angles(math.rad(-25*i), 0, math.rad(30*i))
  414. wait()
  415. end
  416. neck.C0 = necko
  417. detach(true)
  418. end
  419.  
  420. function fire()
  421. local ball = Part(workspace, false, false, 0, 0, Colors[1], 1, 1, 1, true)
  422. Add.BF(ball)
  423. Add.Sphere(ball)
  424. ball.CFrame = tip1.CFrame * CFrame.new(0, 1.5, 0)
  425. local cf = CFrame.new(handle.Position, handle.CFrame * CFrame.new(0, 0, -5).p)
  426. ball.Velocity = cf.lookVector * -80
  427. local w1, w2, w3 = RAW.C0, LAW.C0
  428. for i = 0, 1, 0.5 do
  429. RAW.C0 = w1 * CFrame.Angles(math.rad(25*i), 0, 0)
  430. LAW.C0 = w2 * CFrame.Angles(math.rad(25*i), 0, 0)
  431. HW.C0 = HWStand * CFrame.Angles(math.rad(-20*i), 0, 0)
  432. wait()
  433. end
  434. for i = 1, 0, -0.2 do
  435. RAW.C0 = w1 * CFrame.Angles(math.rad(25*i), 0, 0)
  436. LAW.C0 = w2 * CFrame.Angles(math.rad(25*i), 0, 0)
  437. HW.C0 = HWStand * CFrame.Angles(math.rad(-20*i), 0, 0)
  438. wait()
  439. end
  440. end
  441.  
  442.  
  443. function select(mouse)
  444. selectanim()
  445. selected = true
  446. mouse.KeyDown:connect(function(key)
  447. key = key:lower()
  448. if key == "q" then
  449. end
  450. end)
  451. local hold = false
  452. mouse.Button1Down:connect(function()
  453. hold = true
  454. coroutine.resume(coroutine.create(function()
  455. mouse.Button1Up:wait()
  456. hold = false
  457. end))
  458. while hold do
  459. local pos = torso.CFrame * CFrame.new(0, 0.85, 0).p
  460. local offset = (pos.Y - mouse.Hit.p.Y) / 60
  461. local mag = (pos - mouse.Hit.p).magnitude / 80
  462. offset = offset / mag
  463. if offset > 1 then offset = 1 elseif offset < -1 then offset = -1 end
  464. RAW.C0 = RAWStand * CFrame.Angles(-offset, 0, 0) * CFrame.new(0, 0, 0)
  465. LAW.C0 = LAWStand * CFrame.Angles(-offset/1.5, 0, offset/5) * CFrame.new(0, 0, 0)
  466. neck.C0 = NeckStand * CFrame.Angles(offset/1.6, 0, 0)
  467. wait()
  468. end
  469. fire()
  470. LAW.C0 = LAWStand
  471. RAW.C0 = RAWStand
  472. neck.C0 = NeckStand
  473. end)
  474. while selected do
  475. BG.cframe = ComputePos(torso.Position, mouse.Hit.p) * CFrame.Angles(0, math.rad(45), 0)
  476. wait()
  477. end
  478. end
  479.  
  480. function deselect(mouse)
  481. selected = false
  482. deselanim()
  483. end
  484.  
  485. bin.Selected:connect(select)
  486. bin.Deselected:connect(deselect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement