Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- players = game.Players
- user=players.LocalPlayer;
- uname=user.Name;
- guis=user.PlayerGui;
- pack=user.Backpack;
- keyDowns={};
- freeKeys={};
- shortcuts={};
- _G.mine=_G.mine or{};
- name='Draw3D';
- url='http://www.roblox.com/asset/?id=%d';
- iconNormal=url:format(96578285);
- iconOnDown=url:format(96584484);
- ver=0;
- drawPixel=0.10;
- _G.drawLimit=_G.drawLimit or 1000;
- _G.drawColor=_G.drawColor or Color3.new();
- destroy=game.remove;
- find=game.findFirstChild;
- new=Instance.new;
- with=function(c)
- return function(p)
- local o=type(c)=='string'and new(c)or c;
- local x=p.Parent;p.Parent=nil;
- for i,v in next,p do
- o[i]=v;
- end;
- if(x)then
- o.Parent=x;
- end;
- return o;
- end;
- end;
- getPlace=function()
- if(find(workspace,'draw')==nil)then
- new('Model',workspace).Name='draw';
- end;
- if(find(workspace.draw,uname)==nil)then
- new('Model',workspace.draw).Name=uname;
- end;
- return workspace.draw[uname];
- end;
- drawLine=function(start,target)
- local gui=with'BlockMesh'{
- Parent=with'Part'{
- CFrame=CFrame.new(start,target)*CFrame.new(0,0,-(start-target).magnitude/2);
- Size=Vector3.new(drawPixel,drawPixel,(start-target).magnitude+.325*drawPixel);
- Parent=getPlace();
- Color=_G.drawColor;
- BottomSurface=0;
- Anchored=true;
- TopSurface=0;
- formFactor=3;
- Name=name;
- }}.Parent;
- table.insert(_G.mine,gui);
- return gui;
- end;
- onDown=function()
- if(drawing)then
- return nil;
- end;
- if(selectGui.Adornee)then
- destroy(selectGui.Adornee);
- end;
- drawing=true;
- mouse.Icon=iconOnDown;
- ver=ver+1;
- local cVer,start,target=ver,mouse.hit.p;
- local group={};
- repeat
- Wait(0.02);
- if(mouse.target and mouse.target.Name~=name and mouse.hit.p~=start)then
- target=mouse.hit.p;
- table.insert(group,drawLine(start,target));
- start=target;
- end;
- until ver~=cVer;
- drawing=false;
- local groupM=new('Model',getPlace());
- for i,v in next,group do
- if(v:IsDescendantOf(Workspace))then
- v.Parent=groupM;
- end;
- end;
- if(next(groupM:children())==nil)then
- destroy(groupM);
- end;
- end;
- onUp=function()
- mouse.Icon=iconNormal;
- ver=ver+1;
- end;
- onKeyDown=function(k)
- if(freeKeys[k]==false)then
- return false;
- end;
- freeKeys[k]=false;
- Wait(0.01);
- if(keyDowns[k])then
- keyDowns[k]();
- elseif(shortcuts[k])then
- shortcuts[k]();
- end;
- end;
- onKeyUp=function(k)
- freeKeys[k]=true;
- end;
- onMove=function()
- end;
- onSelect=function(lmouse)
- frame.Visible=true;
- mouse=lmouse;
- mouse.Icon=iconNormal;
- mouse.Button1Down:connect(onDown);
- mouse.KeyDown:connect(onKeyDown);
- mouse.Button1Up:connect(onUp);
- mouse.KeyUp:connect(onKeyUp);
- mouse.Move:connect(onMove);
- end;
- onDeselect=function()
- ver=ver+1;
- frame.Visible=false;
- selectGui.Adornee=nil;
- mouse.Icon=iconNormal;
- for i,v in next,freeKeys do
- freeKeys[i]=true;
- end;
- end;
- addButton=function(title,shortcut,fun)
- with'TextButton'{
- Text=string.format(' %s (%s)',title,shortcut);
- TextXAlignment=0;
- Parent=frame;
- }.MouseButton1Up:connect(fun);
- shortcuts[shortcut]=fun;
- local c=#frame:children();
- for i,v in next,frame:children()do
- v.Position=UDim2.new(0,0,0,20*(i-1));
- v.Size=UDim2.new(1,0,0,20);
- end;
- frame.Position=UDim2.new(1,-152,.5,-c*10);
- frame.Size=UDim2.new(0,150,0,c*20);
- end;
- for i,v in next,{guis;pack;}do
- pcall(function()
- repeat until destroy(v[name]);
- end);
- end;
- tool=with'HopperBin'{
- Parent=pack;
- Name=name;
- };
- tool.Deselected:connect(onDeselect);
- tool.Selected:connect(onSelect);
- screen=with'ScreenGui'{
- Parent=guis;
- Name=name;
- };
- frame=with'Frame'{
- Parent=screen;
- Visible=false;
- };
- clframe=with'Frame'{
- Position=UDim2.new(.5,-50,.5,-50);
- Size=UDim2.new(0,100,0,100);
- Visible=false;
- Parent=screen;
- };
- selectGui=with'SelectionBox'{
- Parent=screen;
- };
- local c=0;
- for y=0,7 do
- for x=0,7 do
- local color=BrickColor.palette(c).Color;
- with'ImageButton'{
- Position=UDim2.new(.125*x,0,.125*y);
- Size=UDim2.new(.125,0,.125);
- BackgroundColor3=color;
- Parent=clframe;
- }.MouseButton1Up:connect(function()
- clframe.Visible=false;
- _G.drawColor=color;
- end);
- c=c+1;
- end;
- end;
- addButton('Color','c',function()
- clframe.Visible=true;
- end);
- addButton('Remove your draws','r',function()
- repeat
- destroy(_G.mine[1]);
- table.remove(_G.mine,1);
- Wait(0.01);
- until nil;
- end);
- addButton('Remove global draws','k',function()
- destroy(workspace.draw);
- while(_G.mine[1])do
- destroy(_G.mine[1]);
- table.remove(_G.mine,1);
- end;
- end);
- addButton('Remove selected','x',function()
- repeat
- if(find(workspace,'draw'))then
- local dt=mouse.target;
- if(dt and dt:IsDescendantOf(workspace.draw))then
- selectGui.Adornee=dt.Parent;
- else
- selectGui.Adornee=nil;
- end;
- else
- selectGui.Adornee=nil;
- end;
- Wait(0.01);
- until freeKeys.x;
- selectGui.Adornee=nil;
- end);
- repeat
- Wait(0.01);
- if(next(_G.mine)and _G.mine[_G.drawLimit])then
- destroy(_G.mine[1]);
- table.remove(_G.mine,1);
- end;
- until script.Parent==nil or tool.Parent==nil;
- script.Disabled=true;
- destroy(screen);
Add Comment
Please, Sign In to add comment