Advertisement
memberhero

xGun SB Fix

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