Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Glock Script Loaded!")
- wait(0.25);
- _clear=function()
- local c={char;bag;gui;};
- for i=1,#c do
- local c=c[i]:children();
- for i=1,#c do
- if(c[i].Name==name)then
- c[i].Parent=nil;
- end;
- end;
- end;
- local n=name..user.Name;
- local c=workspace:children();
- for i=1,#c do
- if(c[i].Name==n)then
- c[i].Parent=nil;
- end;
- end;
- end;
- _valid_key=function(object,key)
- return object[key],key;
- end;
- _new=function(class)
- return function(props)
- if(type(list_base_props)=='table')then
- for i,v in next,list_base_props do
- if(props[i]==nil)then
- props[i]=v;
- end;
- end;
- end;
- local object=class;
- if(type(class)=='string')then
- object=Instance.new(class:sub(1,1):upper()..class:sub(2));
- end;
- local parent=props[1];
- props[1]=nil;
- for i,v in next,props do
- local load,res,key=pcall(_valid_key,object,i:sub(1,1):upper()..i:sub(2));
- if(not load)then
- load,res,key=pcall(_valid_key,object,i);
- end;
- if(key)then
- t=type(res);
- s=tostring(res);
- if(t=='userdata'and s=='Signal '..key)then
- if(type(v)=='table')then
- for i=1,#v do
- res:connect(v[i]);
- end;
- else
- res:connect(v);
- end;
- else
- object[key]=v;
- end;
- end;
- end;
- if(parent)then
- object.Parent=parent;
- end;
- return object;
- end;
- end;
- _RGB=function(r,g,b)
- return Color3.new(r/255,g/255,b/255);
- end;
- _copy=function(o)
- local def=o.archivable;
- o.archivable=true;
- local c=o:clone();
- o.archivable=def;
- return c;
- end;
- _hum=function(char)
- local hum=char:findFirstChild'Humanoid';
- if(not hum or hum.className~='Humanoid')then
- local c=char:children();
- for i=1,#c do
- if(c[i].className=='Humanoid')then
- return c[i];
- end;
- end;
- else
- return hum;
- end;
- end;
- _hum_tag=function(hum)
- local c=hum:findFirstChild'creator'or Instance.new('ObjectValue',hum);
- c.Name='creator';
- c.Value=user;
- if(hum.Health==0 and not hum:findFirstChild'killed')then
- Instance.new('BoolValue',hum).Name='killed';
- bullets.clip=bullets.clip;
- end;
- end;
- _hum_dam=function(hum,dam,percent)
- hum.Health=hum.Health-(percent and hum.MaxHealth*(dam*0.01)or dam);
- if(hum.Health<=hum.MaxHealth*0.1)then
- _hum_tag(hum);
- end;
- end;
- _ray=function(v0,v1,i)
- local mag=(v0-v1).magnitude;
- local ray=Ray.new(v0,(v1-v0).unit*(mag>999 and 999 or mag));
- return(type(i)=='table'and workspace.FindPartOnRayWithIgnoreList or workspace.FindPartOnRay)(workspace,ray,i);
- end;
- _must=function(v0,v1,i)
- local hit,pos=_ray(v0,v1,i);
- return not hit and mouse.target or hit,pos;
- end;
- _cframe=function(x,y,z,r0,r1,r2)
- return CFrame.Angles(
- math.rad(r0 or 0),
- math.rad(r1 or 0),
- math.rad(r2 or 0)
- )*CFrame.new(x,y,z);
- end;
- _update=function()
- if(bool_active and not screen.Parent)then
- screen.Parent=gui;
- elseif(not bool_active and screen.Parent)then
- screen.Parent=nil;
- end;
- end;
- _light=function(v0,v1)
- local mag=(v0-v1).magnitude;
- local len=math.random(2,7);
- len=len>mag/2 and mag/2 or len;
- --[[ local light=_new'part'{
- cFrame=CFrame.new(v0,v1);
- size=Vector3.new(1,1,1);
- color=_RGB(255,255,0);
- anchored=true;
- inv;
- };]]
- _new'blockMesh'{
- scale=Vector3.new(0.2,0.2,len);
- offset=Vector3.new(0,0,-len/2);
- light;
- };
- local bb=_new'billboardGui'{
- size=UDim2.new(2,0,2,0);
- adornee=light;
- light;
- };
- _new'imageLabel'{
- image=url:format(109101526);
- backgroundTransparency=1;
- size=UDim2.new(1,0,1,0);
- bb;
- };
- -- _rem(light,0.15);
- end;
- _rem=function(object,del)
- if(del)then
- delay(del,function()
- if(object.Parent)then
- object.Parent=nil;
- end;
- end);
- else
- pcall(function()
- if(object.Parent)then
- object.Parent=nil;
- end;
- end);
- end;
- end;
- _blood=function(pos,count)
- for i=1,count do
- local p=_new'part'{
- rotVelocity=Vector3.new(math.random(),math.random(),math.random())*50;
- position=pos+Vector3.new(math.random(),math.random(),math.random());
- velocity=Vector3.new(math.random(),math.random(),math.random())*50;
- size=Vector3.new(math.random(),math.random(),math.random())/3;
- color=_RGB(255,0,0);
- transparency=0.5;
- canCollide=true;
- bottomSurface=0;
- topSurface=0;
- formFactor=3;
- locked=true;
- inv;
- };
- delay(5,function()
- p.Parent=nil;
- end);
- end;
- end;
- _make_hue=function()
- h_hue=_new'part'{
- size=Vector3.new(0.25,1.8,0.35);
- color=_RGB(100,100,100);
- formFactor=3;
- name='hue';
- handle;
- };
- hh_weld=_new'weld'{
- c1=_cframe(0,0.5,0);
- part0=handle;
- part1=h_hue;
- handle;
- };
- end;
- _shot=function(v0,v1)
- if(not time_left)then
- time_left=0;
- end;
- if(time_left>time())then
- return nil;
- else
- time_left=time()+math.random(1,10)/100;
- end;
- if(bullets.current<1)then
- local tick_sound=head:findFirstChild'tick_sound'or _new'sound'{
- soundId='rbxasset://sounds/SWITCH3.wav';
- name='tick_sound';
- volume=0.2;
- pitch=2;
- head;
- };
- tick_sound:play();
- if(bullets.clip>0)then
- time_left=time()+2;
- h_hue:breakJoints();
- h_hue.CanCollide=true;
- h_hue.Velocity=(h_hue.CFrame*CFrame.new(0,5,0)).lookVector*10;
- _rem(h_hue,10);
- delay(1.9,function()
- _make_hue();
- local got=(bullets.clip>bullets.maximum and
- bullets.maximum or
- bullets.clip)-bullets.current;
- bullets.clip=bullets.clip-got;
- bullets.current=bullets.current+got;
- end);
- end;
- return nil;
- else
- bullets.current=bullets.current-1;
- h_weld.C1=_cframe(0,0.75,0,
- -math.random(1000,1100)/10,180,0);
- d_weld.C1=_cframe(0,-0.25,0.3);
- --[[lightstuff.Visible=true;
- delay(0.1,function()
- lightstuff.Visible=false;
- end);]]
- _rem(_new'part'{
- velocity=CFrame.new(drag.Position,(drag.CFrame*CFrame.new(-4,-5,0)).p).lookVector*10;
- cFrame=drag.CFrame*CFrame.new(-0.5,0,0);
- size=Vector3.new(0.1,0.1,0.4);
- color=_RGB(200,200,0);
- material='Slate';
- canCollide=true;
- formFactor=3;
- inv;
- },5);
- delay(0.1,function()
- d_weld.C1=_cframe(0,-0.25,0);
- if(bool_active)then
- h_weld.C1=h_weld_cf_active;
- end;
- end)
- end;
- local hit,pos=_must(v0,v1,char);
- shot_sound:play();
- _rem(_new'part'{
- cFrame=CFrame.new(v0,pos)*CFrame.new(0,0,-(v0-pos).magnitude*0.5);
- size=Vector3.new(0.1,0.1,(v0-pos).magnitude);
- color=_RGB(255,255,0);
- transparency=0.6;
- reflectance=0.5;
- canCollide=false;
- bottomSurface=0;
- anchored=true;
- formFactor=3;
- topSurface=0;
- inv;
- },.15);
- _light(v0,v1);
- if(not hit)then return nil;end;
- if(hit.Parent.className=='Hat')then
- hit:breakJoints();
- hit.CanCollide=true;
- hit.Velocity=CFrame.new(v0,pos).lookVector*math.random(30,50);
- hit.RotVelocity=Vector3.new(math.random(1,90),math.random(1,90),math.random(1,90));
- else
- local hum=_hum(hit.Parent);
- if(not hum)then
- if(hit.Anchored==false and hit.Size.magnitude<4)then
- hit:breakJoints();
- hit.CanCollide=true;
- end;
- else
- _hum_dam(hum,math.random(15,25));
- _blood(pos,math.random(3,6));
- hit.RotVelocity=Vector3.new(math.random(1,90),math.random(1,90),math.random(1,90))/6;
- if(hit.Name=='Head')then
- hum.Health=0;
- _blood(pos,math.random(3,6));
- --[[delay(0.001,function()
- _new(workspace:FindFirstChild'head_shot'or'sound'){
- pitch=math.random(70,100)*0.01;
- soundId=url:format(1876552);
- name='head_shot';
- workspace;
- }:play();
- end);]]
- _hum_tag(hum);
- --[[_rem(_new'part'{
- cFrame=CFrame.new(v0,pos)*CFrame.new(0,0,-(v0-pos).magnitude*0.5);
- size=Vector3.new(0.1,0.1,(v0-pos).magnitude);
- color=torso.Color;
- transparency=0.5;
- canCollide=false;
- bottomSurface=0;
- anchored=true;
- formFactor=3;
- topSurface=0;
- inv;
- },30);
- hit.Parent=nil;
- for b=0,1 do
- for a=0,1 do
- for i=0,1 do
- _rem(_new'part'{
- velocity=CFrame.new(v0,pos).lookVector*20;
- cFrame=hit.CFrame*CFrame.new(i,-b,a);
- size=Vector3.new(0.5,0.5,0.5);
- color=_RGB(255,255,255);
- bottomSurface=0;
- canCollide=true;
- transparency=0;
- formFactor=3;
- topSurface=0;
- hum;
- },30);
- end;
- end;
- end;]]
- end;
- end;
- end;
- end;
- _cf_select=function(mouse)
- mouse.Icon=url:format(109111387);--108999296
- bool_active=true;
- local arm=char:findFirstChild'Right Arm';
- local weld=torso:findFirstChild'Right Shoulder';
- if(arm and weld)then
- h_weld.Part0=arm;
- h_weld.C1=h_weld_cf_active;
- weld.Part1=nil;
- weld.Part0=nil;
- weld=_new(torso:findFirstChild'right_arml'or'weld'){
- name='right_arml';
- part0=torso;
- part1=arm;
- torso;
- };
- arml=(arml or 0)+1;
- local alv=arml;
- local gyro=torso:findFirstChild'p_gyro'or Instance.new('BodyGyro',torso);
- gyro.maxTorque=Vector3.new(5e5,5e5,5e5);
- gyro.P=30000;
- gyro.D=1000;
- gyro.Name='p_gyro';
- repeat
- local pos=mouse.hit.p;
- local val,valp,p0,p1,p2,hitpos,cj,c0,c1;
- val=-math.pi*0.5;
- valp=val*-1;
- p0=torso.CFrame;
- p0=p0+((p0*CFrame.Angles(valp,0,0)).lookVector*0.5)+(p0*CFrame.Angles(0,val,0)).lookVector;
- p1=p0+((p0.p-pos).unit*-2);
- p2=CFrame.new((p0.p+p1.p)/2,p0.p)*CFrame.Angles(val,val,0);
- hitpos=torso.Position;
- cj=CFrame.new(hitpos);
- c0=torso.CFrame:inverse()*cj;
- c1=p2:inverse()*cj;
- weld.C0=c0;
- weld.C1=c1;
- gyro.cframe=CFrame.new(torso.Position,Vector3.new(pos.X,torso.Position.Y,pos.Z));
- wait(0.001);
- until arml~=alv;
- gyro.Parent=nil;
- end;
- end;
- _cf_deselect=function()
- bool_active=false;
- arml=(arml or 0)+1;
- loop_shot=(loop_shot or 0)+1;
- h_weld.Part0=torso;
- h_weld.C1=h_weld_cf_inactive;
- local weld=torso:findFirstChild'right_arml';
- if(weld)then
- weld.Part1=nil;
- weld.Part0=nil;
- end;
- local arm=char:findFirstChild'Right Arm';
- local weld=torso:findFirstChild'Right Shoulder';
- if(arm and weld)then
- weld.Part0=torso;
- weld.Part1=arm;
- end;
- end;
- _cf_mouse=function(event,fun)
- mouse[event:sub(1,1):upper()..event:sub(2)]:connect(function(...)
- if(bool_active)then
- fun(...);
- end;
- end);
- end;
- do
- local main=getfenv(0);
- local c=game:children();
- local check=function(v)
- if(v.className~=''and v.className~='Instance'and game:service(v.className))then
- main[v.className:sub(1,1):lower()..v.className:sub(2)]=v;
- end;
- end;
- for i=1,#c do
- pcall(check,c[i]);
- end;
- end;
- bullets={
- maximum=33;
- current=33;
- clip=600;
- };
- list_base_props={
- backgroundColor3=_RGB(0,0,0);
- textColor3=_RGB(200,200,200);
- borderSizePixel=0;
- color=_RGB(0,0,0);
- archivable=false;
- canCollide=false;
- bottomSurface=0;
- topSurface=0;
- formFactor=0;
- locked=true;
- };
- user=players.localPlayer;
- mouse=user:getMouse();
- char=user.Character;
- gui=user.PlayerGui;
- bag=user.Backpack;
- torso=char.Torso;
- head=char.Head;
- hum=_hum(char);
- url='rbxassetid://%d';
- name='GLOCK 18 Machine Pistol';
- h_weld_cf_inactive=_cframe(0.35,0.5,0.5,
- 0,90,-70);
- h_weld_cf_active=_cframe(0,0.75,0,
- -110,180,0);
- assert(hum,'humanoid is not found');
- _clear();
- _cf_mouse('button1Down',function()
- loop_shot=(loop_shot or 0)+1;
- local vers=loop_shot;
- local step=runService.Stepped;
- repeat
- _shot((tube.CFrame*CFrame.new(0,0,tube.Size.Z*0.5)).p,mouse.hit.p);
- step:wait(0.005);--wait(0.001);
- until vers~=loop_shot;
- end);
- _cf_mouse('button1Up',function()
- loop_shot=(loop_shot or 0)+1;
- end);
- _cf_mouse('move',function()
- cross_f.Position=UDim2.new(0,mouse.X-11,0,mouse.Y-11);
- end);
- _cf_mouse('keyDown',function(k)
- if(k=='r')then
- if(bullets.clip>0 and time_left<=time())then
- local got=(bullets.clip>bullets.maximum and
- bullets.maximum or
- bullets.clip)-bullets.current;
- bullets.clip=bullets.clip-got;
- bullets.current=bullets.current+got;
- if(got~=0)then
- time_left=time()+2;
- end;
- end;
- end;
- end);
- screen=_new'screenGui'{
- name=name;
- };
- cross_f=_new'frame'{
- size=UDim2.new(0,21,0,21);
- backgroundTransparency=1;
- screen;
- };
- for i=0,1 do
- _new'frame'{
- position=UDim2.new(0,13*i,0,11);
- size=UDim2.new(0,10,0,1);
- cross_f;
- };
- end;
- for i=0,1 do
- _new'frame'{
- position=UDim2.new(0,11,0,13*i);
- size=UDim2.new(0,1,0,10);
- cross_f;
- };
- end;
- shot_sound=_new(head:findFirstChild'2920959'or'sound'){
- soundId=url:format(2920959);
- pitch=1.4;
- head;
- };
- if(shot_sound.Name~='2920959')then
- shot_sound.Name='2920959';
- shot_sound:play();
- end;
- bin=_new'hopperBin'{
- deselected=_cf_deselect;
- selected=_cf_select;
- name=name;
- bag;
- };
- inv=_new'model'{
- name=name;
- char;
- };
- handle=_new'part'{
- size=Vector3.new(0.3,1.3,0.4);
- color=_RGB(140,140,140);
- name='handle';
- material='Metal';
- formFactor=3;
- inv;
- touched=function(hit)
- if(hit.Parent.className=='Model')then
- local hum=_hum(hit.Parent);
- if(hum~=nil)then
- _hum_dam(hum,handle.Velocity.magnitude);
- end;
- end;
- end;
- };
- h_weld=_new'weld'{
- c1=h_weld_cf_inactive;
- part1=handle;
- part0=torso;
- handle;
- };
- _make_hue();
- h_part=_new'part'{
- size=Vector3.new(0.4,0.4,1.4);
- color=_RGB(140,140,140);
- name='handle';
- formFactor=3;
- handle;
- };
- hp_weld=_new'weld'{
- c1=_cframe(0,-1.3/2,-0.3,
- 20,0,0);
- part0=handle;
- part1=h_part;
- handle;
- };
- drag=_new'part'{
- size=Vector3.new(0.5,0.45,1.5);
- color=_RGB(100,100,100);
- name='handle';
- formFactor=3;
- handle;
- };
- d_weld=_new'weld'{
- c1=_cframe(0,-0.25,0);
- part0=h_part;
- part1=drag;
- handle;
- };
- tube=_new'part'{
- size=Vector3.new(0.2,0.2,1.5);
- color=_RGB(0,0,0);
- name='handle';
- formFactor=3;
- handle;
- };
- t_weld=_new'weld'{
- c1=_cframe(0,-0.3,-0.1);
- part0=h_part;
- part1=tube;
- handle;
- };
- bullets_label=_new'textLabel'{
- textStrokeColor3=_RGB(0,0,0);
- textColor3=_RGB(200,200,200);
- textStrokeTransparency=0;
- backgroundTransparency=1;
- fontSize=5;
- screen;
- };
- lightstuff=_new'frame'{
- backgroundColor3=_RGB(255,255,255);
- position=UDim2.new(0,0,0,-1);
- backgroundTransparency=0.5;
- size=UDim2.new(1,0,1,1);
- borderSizePixel=0;
- visible=false;
- screen;
- };
- coroutine.wrap(function()
- local red,white,green;
- repeat
- if(screen.Parent)then
- if(not green and bullets.current==bullets.maximum)then
- green=true;
- bullets_label.TextColor3=_RGB(0,200,0);
- elseif(not red and bullets.current==0)then
- red=true;
- bullets_label.TextColor3=_RGB(200,0,0);
- elseif((red or green)and bullets.current~=0 and bullets.current~=bullets.maximum)then
- bullets_label.TextColor3=_RGB(200,200,200);
- green=false;
- red=false;
- end;
- bullets_label.Text=('Bullets: '..bullets.current..'/'..bullets.clip..""):format(bullets.current,bullets.clip);
- bullets_label.Size=UDim2.new(0,bullets_label.TextBounds.X,0,bullets_label.TextBounds.Y);
- bullets_label.Position=UDim2.new(1,-bullets_label.TextBounds.X-6,1,-bullets_label.TextBounds.Y-6);
- end;
- wait(0.001);
- until nil;
- end)();
- _G.dev_pistol_version=(_G.dev_pistol_version or 0)+1;
- local vers=_G.dev_pistol_version;
- repeat _update();wait(0.001);until _G.dev_pistol_version~=vers or hum.Health==0;
- if(hum.Health==0)then
- _clear();
- end;
Add Comment
Please, Sign In to add comment