Advertisement
Guest User

gun script made by Lust

a guest
Mar 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.94 KB | None | 0 0
  1. print("guns starting")
  2. wait(0.25);
  3.  
  4.  
  5. _clear=function()
  6. local c={char;bag;gui;};
  7. for i=1,#c do
  8. local c=c[i]:children();
  9. for i=1,#c do
  10. if(c[i].Name==name)then
  11. c[i].Parent=nil;
  12. end;
  13. end;
  14. end;
  15. local n=name..user.Name;
  16. local c=workspace:children();
  17. for i=1,#c do
  18. if(c[i].Name==n)then
  19. c[i].Parent=nil;
  20. end;
  21. end;
  22. end;
  23.  
  24. _valid_key=function(object,key)
  25. return object[key],key;
  26. end;
  27.  
  28. _new=function(class)
  29. return function(props)
  30. if(type(list_base_props)=='table')then
  31. for i,v in next,list_base_props do
  32. if(props[i]==nil)then
  33. props[i]=v;
  34. end;
  35. end;
  36. end;
  37.  
  38. local object=class;
  39.  
  40. if(type(class)=='string')then
  41. object=Instance.new(class:sub(1,1):upper()..class:sub(2));
  42. end;
  43.  
  44. local parent=props[1];
  45. props[1]=nil;
  46.  
  47. for i,v in next,props do
  48. local load,res,key=pcall(_valid_key,object,i:sub(1,1):upper()..i:sub(2));
  49. if(not load)then
  50. load,res,key=pcall(_valid_key,object,i);
  51. end;
  52.  
  53. if(key)then
  54. t=type(res);
  55. s=tostring(res);
  56. if(t=='userdata'and s=='Signal '..key)then
  57. if(type(v)=='table')then
  58. for i=1,#v do
  59. res:connect(v[i]);
  60. end;
  61. else
  62. res:connect(v);
  63. end;
  64. else
  65. object[key]=v;
  66. end;
  67. end;
  68. end;
  69.  
  70. if(parent)then
  71. object.Parent=parent;
  72. end;
  73.  
  74. return object;
  75. end;
  76. end;
  77.  
  78. _RGB=function(r,g,b)
  79. return Color3.new(r/255,g/255,b/255);
  80. end;
  81.  
  82. _copy=function(o)
  83. local def=o.archivable;
  84. o.archivable=true;
  85. local c=o:clone();
  86. o.archivable=def;
  87. return c;
  88. end;
  89.  
  90. _hum=function(char)
  91. local hum=char:findFirstChild'Humanoid';
  92. if(not hum or hum.className~='Humanoid')then
  93. local c=char:children();
  94. for i=1,#c do
  95. if(c[i].className=='Humanoid')then
  96. return c[i];
  97. end;
  98. end;
  99. else
  100. return hum;
  101. end;
  102. end;
  103.  
  104. _hum_tag=function(hum)
  105. local c=hum:findFirstChild'creator'or Instance.new('ObjectValue',hum);
  106. c.Name='creator';
  107. c.Value=user;
  108. if(hum.Health==0 and not hum:findFirstChild'killed')then
  109. Instance.new('BoolValue',hum).Name='killed';
  110. bullets.clip=bullets.clip+10;
  111. end;
  112. end;
  113.  
  114. _hum_dam=function(hum,dam,percent)
  115. hum.Health=hum.Health-(percent and hum.MaxHealth*(dam*0.01)or dam);
  116. if(hum.Health<=hum.MaxHealth*0.1)then
  117. _hum_tag(hum);
  118. end;
  119. end;
  120.  
  121. _ray=function(v0,v1,i)
  122. local mag=(v0-v1).magnitude;
  123. local ray=Ray.new(v0,(v1-v0).unit*(mag>999 and 999 or mag));
  124.  
  125. return(type(i)=='table'and workspace.FindPartOnRayWithIgnoreList or workspace.FindPartOnRay)(workspace,ray,i);
  126. end;
  127.  
  128. _must=function(v0,v1,i)
  129. local hit,pos=_ray(v0,v1,i);
  130. return not hit and mouse.target or hit,pos;
  131. end;
  132.  
  133. _cframe=function(x,y,z,r0,r1,r2)
  134. return CFrame.Angles(
  135. math.rad(r0 or 0),
  136. math.rad(r1 or 0),
  137. math.rad(r2 or 0)
  138. )*CFrame.new(x,y,z);
  139. end;
  140.  
  141. _update=function()
  142. if(bool_active and not screen.Parent)then
  143. screen.Parent=gui;
  144. elseif(not bool_active and screen.Parent)then
  145. screen.Parent=nil;
  146. end;
  147. end;
  148.  
  149. _light=function(v0,v1)
  150. local mag=(v0-v1).magnitude;
  151. local len=math.random(2,7);
  152. len=len>mag/2 and mag/2 or len;
  153.  
  154. --local light=_new'part'{
  155. -- cFrame=CFrame.new(v0,v1);
  156. -- size=Vector3.new(1,1,1);
  157. -- color=_RGB(255,255,0);
  158. -- anchored=true;
  159. -- inv;
  160. --};
  161. _new'blockMesh'{
  162. scale=Vector3.new(0.2,0.2,len);
  163. offset=Vector3.new(0,0,-len/2);
  164. light;
  165. };
  166.  
  167. local bb=_new'billboardGui'{
  168. size=UDim2.new(2,0,2,0);
  169. adornee=light;
  170. light;
  171. };
  172. _new'imageLabel'{
  173. image=url:format(109101526);
  174. backgroundTransparency=1;
  175. size=UDim2.new(1,0,1,0);
  176. bb;
  177. };
  178.  
  179. -- _rem(light,0.15);
  180. end;
  181.  
  182. _rem=function(object,del)
  183. if(del)then
  184. delay(del,function()
  185. if(object.Parent)then
  186. object.Parent=nil;
  187. end;
  188. end);
  189. else
  190. pcall(function()
  191. if(object.Parent)then
  192. object.Parent=nil;
  193. end;
  194. end);
  195. end;
  196. end;
  197.  
  198. _blood=function(pos,count)
  199. for i=1,count do
  200. local p=_new'part'{
  201. rotVelocity=Vector3.new(math.random(),math.random(),math.random())*50;
  202. position=pos+Vector3.new(math.random(),math.random(),math.random());
  203. velocity=Vector3.new(math.random(),math.random(),math.random())*50;
  204. size=Vector3.new(math.random(),math.random(),math.random())/3;
  205. color=_RGB(255,0,0);
  206. transparency=0.5;
  207. canCollide=true;
  208. bottomSurface=0;
  209. topSurface=0;
  210. formFactor=3;
  211. locked=true;
  212. inv;
  213. };
  214. delay(5,function()
  215. p.Parent=nil;
  216. end);
  217. end;
  218. end;
  219.  
  220. _make_hue=function()
  221. h_hue=_new'part'{
  222. size=Vector3.new(0.25,1.8,0.35);
  223. color=_RGB(100,100,100);
  224. formFactor=3;
  225. name='hue';
  226. handle;
  227. };
  228. hh_weld=_new'weld'{
  229. c1=_cframe(0,0.5,0);
  230. part0=handle;
  231. part1=h_hue;
  232. handle;
  233. };
  234. end;
  235.  
  236. _shot=function(v0,v1)
  237. if(not time_left)then
  238. time_left=0;
  239. end;
  240. if(time_left>time())then
  241. return nil;
  242. else
  243. time_left=time()+math.random(1,10)/100;
  244. end;
  245.  
  246. if(bullets.current<1)then
  247. local tick_sound=head:findFirstChild'tick_sound'or _new'sound'{
  248. soundId='rbxasset://sounds/SWITCH3.wav';
  249. name='tick_sound';
  250. volume=0.2;
  251. pitch=2;
  252. head;
  253. };
  254. tick_sound:play();
  255. if(bullets.clip>0)then
  256. time_left=time()+2;
  257. h_hue:breakJoints();
  258. h_hue.CanCollide=true;
  259. h_hue.Velocity=(h_hue.CFrame*CFrame.new(0,5,0)).lookVector*10;
  260. _rem(h_hue,10);
  261. delay(1.9,function()
  262. _make_hue();
  263. local got=(bullets.clip>bullets.maximum and
  264. bullets.maximum or
  265. bullets.clip)-bullets.current;
  266.  
  267. bullets.clip=bullets.clip-got;
  268. bullets.current=bullets.current+got;
  269. end);
  270. end;
  271. return nil;
  272. else
  273. bullets.current=bullets.current-1;
  274.  
  275. h_weld.C1=_cframe(0,0.75,0,
  276. -math.random(1000,1100)/10,180,0);
  277. d_weld.C1=_cframe(0,-0.25,0.3);
  278.  
  279. lightstuff.Visible=true;
  280. delay(0.1,function()
  281. lightstuff.Visible=false;
  282. end);
  283.  
  284. _rem(_new'part'{
  285. velocity=CFrame.new(drag.Position,(drag.CFrame*CFrame.new(-4,-5,0)).p).lookVector*10;
  286. cFrame=drag.CFrame*CFrame.new(-0.5,0,0);
  287. size=Vector3.new(0.1,0.1,0.4);
  288. color=_RGB(200,200,0);
  289. material='Slate';
  290. canCollide=true;
  291. formFactor=3;
  292. inv;
  293. },5);
  294.  
  295. delay(0.1,function()
  296. d_weld.C1=_cframe(0,-0.25,0);
  297. if(bool_active)then
  298. h_weld.C1=h_weld_cf_active;
  299. end;
  300. end)
  301. end;
  302.  
  303. local hit,pos=_must(v0,v1,char);
  304.  
  305. shot_sound:play();
  306.  
  307.  
  308. _rem(_new'part'{
  309. cFrame=CFrame.new(v0,pos)*CFrame.new(0,0,-(v0-pos).magnitude*0.5);
  310. size=Vector3.new(0.1,0.1,(v0-pos).magnitude);
  311. color=_RGB(255,255,0);
  312. transparency=0.6;
  313. reflectance=0.5;
  314. canCollide=false;
  315. bottomSurface=0;
  316. anchored=true;
  317. formFactor=3;
  318. topSurface=0;
  319. inv;
  320. },.15);
  321. _light(v0,v1);
  322.  
  323. if(not hit)then return nil;end;
  324.  
  325. if(hit.Parent.className=='Hat')then
  326. hit:breakJoints();
  327. hit.CanCollide=true;
  328. hit.Velocity=CFrame.new(v0,pos).lookVector*math.random(30,50);
  329. hit.RotVelocity=Vector3.new(math.random(1,90),math.random(1,90),math.random(1,90));
  330. else
  331. local hum=_hum(hit.Parent);
  332. if(not hum)then
  333. if(hit.Anchored==false and hit.Size.magnitude<4)then
  334. hit:breakJoints();
  335. hit.CanCollide=true;
  336. end;
  337. else
  338. _hum_dam(hum,math.random(4,6));
  339. _blood(pos,math.random(3,6));
  340. hit.RotVelocity=Vector3.new(math.random(1,90),math.random(1,90),math.random(1,90))/6;
  341. if(hit.Name=='Head')then
  342. hum.Health=0;
  343. _blood(pos,math.random(3,6));
  344. delay(0.001,function()
  345. _new(workspace:FindFirstChild'head_shot'or'sound'){
  346. pitch=math.random(70,100)*0.01;
  347. soundId=url:format(1876552);
  348. name='head_shot';
  349. workspace;
  350. }:play();
  351. end);
  352. _hum_tag(hum);
  353. _rem(_new'part'{
  354. cFrame=CFrame.new(v0,pos)*CFrame.new(0,0,-(v0-pos).magnitude*0.5);
  355. size=Vector3.new(0.1,0.1,(v0-pos).magnitude);
  356. color=torso.Color;
  357. transparency=0.5;
  358. canCollide=false;
  359. bottomSurface=0;
  360. anchored=true;
  361. formFactor=3;
  362. topSurface=0;
  363. inv;
  364. },30);
  365. hit.Parent=nil;
  366. for b=0,1 do
  367. for a=0,1 do
  368. for i=0,1 do
  369. _rem(_new'part'{
  370. velocity=CFrame.new(v0,pos).lookVector*20;
  371. cFrame=hit.CFrame*CFrame.new(i,-b,a);
  372. size=Vector3.new(0.5,0.5,0.5);
  373. color=_RGB(255,255,255);
  374. bottomSurface=0;
  375. canCollide=true;
  376. transparency=0;
  377. formFactor=3;
  378. topSurface=0;
  379. hum;
  380. },30);
  381. end;
  382. end;
  383. end;
  384. end;
  385. end;
  386. end;
  387. end;
  388.  
  389.  
  390.  
  391. _cf_select=function(mouse)
  392. mouse.Icon=url:format(109111387);--108999296
  393. bool_active=true;
  394.  
  395. local arm=char:findFirstChild'Right Arm';
  396. local weld=torso:findFirstChild'Right Shoulder';
  397. if(arm and weld)then
  398. h_weld.Part0=arm;
  399. h_weld.C1=h_weld_cf_active;
  400.  
  401. weld.Part1=nil;
  402. weld.Part0=nil;
  403.  
  404. weld=_new(torso:findFirstChild'right_arml'or'weld'){
  405. name='right_arml';
  406. part0=torso;
  407. part1=arm;
  408. torso;
  409. };
  410.  
  411. arml=(arml or 0)+1;
  412. local alv=arml;
  413. local gyro=torso:findFirstChild'p_gyro'or Instance.new('BodyGyro',torso);
  414. gyro.maxTorque=Vector3.new(5e5,5e5,5e5);
  415. gyro.P=30000;
  416. gyro.D=1000;
  417. gyro.Name='p_gyro';
  418. repeat
  419. local pos=mouse.hit.p;
  420. local val,valp,p0,p1,p2,hitpos,cj,c0,c1;
  421.  
  422. val=-math.pi*0.5;
  423. valp=val*-1;
  424. p0=torso.CFrame;
  425. p0=p0+((p0*CFrame.Angles(valp,0,0)).lookVector*0.5)+(p0*CFrame.Angles(0,val,0)).lookVector;
  426. p1=p0+((p0.p-pos).unit*-2);
  427. p2=CFrame.new((p0.p+p1.p)/2,p0.p)*CFrame.Angles(val,val,0);
  428. hitpos=torso.Position;
  429. cj=CFrame.new(hitpos);
  430. c0=torso.CFrame:inverse()*cj;
  431. c1=p2:inverse()*cj;
  432. weld.C0=c0;
  433. weld.C1=c1;
  434.  
  435. gyro.cframe=CFrame.new(torso.Position,Vector3.new(pos.X,torso.Position.Y,pos.Z));
  436.  
  437. wait(0.001);
  438. until arml~=alv;
  439. gyro.Parent=nil;
  440. end;
  441. end;
  442.  
  443. _cf_deselect=function()
  444. bool_active=false;
  445. arml=(arml or 0)+1;
  446. loop_shot=(loop_shot or 0)+1;
  447.  
  448. h_weld.Part0=torso;
  449. h_weld.C1=h_weld_cf_inactive;
  450.  
  451. local weld=torso:findFirstChild'right_arml';
  452. if(weld)then
  453. weld.Part1=nil;
  454. weld.Part0=nil;
  455. end;
  456. local arm=char:findFirstChild'Right Arm';
  457. local weld=torso:findFirstChild'Right Shoulder';
  458. if(arm and weld)then
  459. weld.Part0=torso;
  460. weld.Part1=arm;
  461. end;
  462. end;
  463.  
  464. _cf_mouse=function(event,fun)
  465. mouse[event:sub(1,1):upper()..event:sub(2)]:connect(function(...)
  466. if(bool_active)then
  467. fun(...);
  468. end;
  469. end);
  470. end;
  471.  
  472.  
  473. do
  474. local main=getfenv(0);
  475. local c=game:children();
  476. local check=function(v)
  477. if(v.className~=''and v.className~='Instance'and game:service(v.className))then
  478. main[v.className:sub(1,1):lower()..v.className:sub(2)]=v;
  479. end;
  480. end;
  481. for i=1,#c do
  482. pcall(check,c[i]);
  483. end;
  484. end;
  485.  
  486.  
  487. bullets={
  488. maximum=600;
  489. current=600;
  490. clip=6;
  491. };
  492.  
  493. list_base_props={
  494. backgroundColor3=_RGB(0,0,0);
  495. textColor3=_RGB(200,200,200);
  496. borderSizePixel=0;
  497. color=_RGB(0,0,0);
  498. archivable=false;
  499. canCollide=false;
  500. bottomSurface=0;
  501. topSurface=0;
  502. formFactor=0;
  503. locked=true;
  504. };
  505.  
  506.  
  507.  
  508. user=players.localPlayer;
  509. mouse=user:getMouse();
  510. char=user.Character;
  511. gui=user.PlayerGui;
  512. bag=user.Backpack;
  513. torso=char.Torso;
  514. head=char.Head;
  515. hum=_hum(char);
  516.  
  517. url='rbxassetid://%d';
  518. name='dev-uzi';
  519.  
  520. h_weld_cf_inactive=_cframe(0.35,0.5,0.5,
  521. 0,90,-70);
  522. h_weld_cf_active=_cframe(0,0.75,0,
  523. -110,180,0);
  524.  
  525. assert(hum,'humanoid is not found');
  526.  
  527.  
  528.  
  529. _clear();
  530.  
  531.  
  532. _cf_mouse('button1Down',function()
  533. loop_shot=(loop_shot or 0)+1;
  534. local vers=loop_shot;
  535. local step=runService.Stepped;
  536. repeat
  537. _shot((tube.CFrame*CFrame.new(0,0,tube.Size.Z*0.5)).p,mouse.hit.p);
  538. step:wait();--wait(0.001);
  539. until vers~=loop_shot;
  540. end);
  541.  
  542. _cf_mouse('button1Up',function()
  543. loop_shot=(loop_shot or 0)+1;
  544. end);
  545.  
  546. _cf_mouse('move',function()
  547. cross_f.Position=UDim2.new(0,mouse.X-11,0,mouse.Y-11);
  548. end);
  549.  
  550. _cf_mouse('keyDown',function(k)
  551. if(k=='r')then
  552. if(bullets.clip>0 and time_left<=time())then
  553. local got=(bullets.clip>bullets.maximum and
  554. bullets.maximum or
  555. bullets.clip)-bullets.current;
  556.  
  557. bullets.clip=bullets.clip-got;
  558. bullets.current=bullets.current+got;
  559. if(got~=0)then
  560. time_left=time()+2;
  561. end;
  562. end;
  563. end;
  564. end);
  565.  
  566.  
  567. screen=_new'screenGui'{
  568. name=name;
  569. };
  570.  
  571. cross_f=_new'frame'{
  572. size=UDim2.new(0,21,0,21);
  573. backgroundTransparency=1;
  574. screen;
  575. };
  576.  
  577. for i=0,1 do
  578. _new'frame'{
  579. position=UDim2.new(0,13*i,0,11);
  580. size=UDim2.new(0,10,0,1);
  581. cross_f;
  582. };
  583. end;
  584.  
  585. for i=0,1 do
  586. _new'frame'{
  587. position=UDim2.new(0,11,0,13*i);
  588. size=UDim2.new(0,1,0,10);
  589. cross_f;
  590. };
  591. end;
  592.  
  593.  
  594.  
  595. shot_sound=_new(head:findFirstChild'2920959'or'sound'){
  596. soundId=url:format(2920959);
  597. pitch=1.4;
  598. head;
  599. };
  600. if(shot_sound.Name~='2920959')then
  601. shot_sound.Name='2920959';
  602. shot_sound:play();
  603. end;
  604.  
  605. bin=_new'hopperBin'{
  606. deselected=_cf_deselect;
  607. selected=_cf_select;
  608. name=name;
  609. bag;
  610. };
  611.  
  612. inv=_new'model'{
  613. name=name;
  614. char;
  615. };
  616.  
  617. handle=_new'part'{
  618. size=Vector3.new(0.3,1.3,0.4);
  619. color=_RGB(140,140,140);
  620. name='handle';
  621. formFactor=3;
  622. inv;
  623. touched=function(hit)
  624. if(hit.Parent.className=='Model')then
  625. local hum=_hum(hit.Parent);
  626. if(hum~=nil)then
  627. _hum_dam(hum,handle.Velocity.magnitude);
  628. end;
  629. end;
  630. end;
  631. };
  632. h_weld=_new'weld'{
  633. c1=h_weld_cf_inactive;
  634. part1=handle;
  635. part0=torso;
  636. handle;
  637. };
  638. _make_hue();
  639.  
  640. h_part=_new'part'{
  641. size=Vector3.new(0.4,0.4,1.4);
  642. color=_RGB(140,140,140);
  643. name='handle';
  644. formFactor=3;
  645. handle;
  646. };
  647. hp_weld=_new'weld'{
  648. c1=_cframe(0,-1.3/2,-0.3,
  649. 20,0,0);
  650. part0=handle;
  651. part1=h_part;
  652. handle;
  653. };
  654.  
  655. drag=_new'part'{
  656. size=Vector3.new(0.5,0.45,1.5);
  657. color=_RGB(100,100,100);
  658. name='handle';
  659. formFactor=3;
  660. handle;
  661. };
  662. d_weld=_new'weld'{
  663. c1=_cframe(0,-0.25,0);
  664. part0=h_part;
  665. part1=drag;
  666. handle;
  667. };
  668.  
  669. tube=_new'part'{
  670. size=Vector3.new(0.2,0.2,1.5);
  671. color=_RGB(0,0,0);
  672. name='handle';
  673. formFactor=3;
  674. handle;
  675. };
  676. t_weld=_new'weld'{
  677. c1=_cframe(0,-0.3,-0.1);
  678. part0=h_part;
  679. part1=tube;
  680. handle;
  681. };
  682.  
  683. bullets_label=_new'textLabel'{
  684. textStrokeColor3=_RGB(0,0,0);
  685. textColor3=_RGB(200,200,200);
  686. textStrokeTransparency=0;
  687. backgroundTransparency=1;
  688. fontSize=5;
  689. screen;
  690. };
  691.  
  692. lightstuff=_new'frame'{
  693. backgroundColor3=_RGB(255,255,255);
  694. position=UDim2.new(0,0,0,-1);
  695. backgroundTransparency=0.5;
  696. size=UDim2.new(1,0,1,1);
  697. borderSizePixel=0;
  698. visible=false;
  699. screen;
  700. };
  701.  
  702. coroutine.wrap(function()
  703. local red,white,green;
  704. repeat
  705. if(screen.Parent)then
  706. if(not green and bullets.current==bullets.maximum)then
  707. green=true;
  708. bullets_label.TextColor3=_RGB(0,200,0);
  709. elseif(not red and bullets.current==0)then
  710. red=true;
  711. bullets_label.TextColor3=_RGB(200,0,0);
  712. elseif((red or green)and bullets.current~=0 and bullets.current~=bullets.maximum)then
  713. bullets_label.TextColor3=_RGB(200,200,200);
  714. green=false;
  715. red=false;
  716. end;
  717. bullets_label.Text=('Bullets: %d/%d'):format(bullets.current,bullets.clip);
  718. bullets_label.Size=UDim2.new(0,bullets_label.TextBounds.X,0,bullets_label.TextBounds.Y);
  719. bullets_label.Position=UDim2.new(1,-bullets_label.TextBounds.X-6,1,-bullets_label.TextBounds.Y-6);
  720. end;
  721. wait(0.001);
  722. until nil;
  723. end)();
  724.  
  725.  
  726. _G.dev_pistol_version=(_G.dev_pistol_version or 0)+1;
  727. local vers=_G.dev_pistol_version;
  728. repeat _update();wait(0.001);until _G.dev_pistol_version~=vers or hum.Health==0;
  729. if(hum.Health==0)then
  730. _clear();
  731. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement