Advertisement
Spacemonkey359

Draw

Mar 19th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. for i,v in next,game:children()do
  2. pcall(function()
  3. local c=v.className;
  4. rawset(getfenv(0),c:sub(1,1):lower()..c:sub(2),game:service(c));
  5. end);
  6. end;
  7.  
  8.  
  9. user=players.LocalPlayer;
  10. uname=user.Name;
  11. guis=user.PlayerGui;
  12. pack=user.Backpack;
  13.  
  14. keyDowns={};
  15. freeKeys={};
  16. shortcuts={};
  17.  
  18. _G.mine=_G.mine or{};
  19.  
  20. name='Draw3D';
  21. url='http://www.roblox.com/asset/?id=%d';
  22.  
  23. iconNormal=url:format(96578285);
  24. iconOnDown=url:format(96584484);
  25.  
  26. ver=0;
  27. drawPixel=0.10;
  28. _G.drawLimit=_G.drawLimit or 1000;
  29.  
  30. _G.drawColor=_G.drawColor or Color3.new();
  31.  
  32.  
  33.  
  34.  
  35.  
  36. destroy=game.remove;
  37. find=game.findFirstChild;
  38. new=Instance.new;
  39. with=function(c)
  40. return function(p)
  41. local o=type(c)=='string'and new(c)or c;
  42. local x=p.Parent;p.Parent=nil;
  43. for i,v in next,p do
  44. o[i]=v;
  45. end;
  46. if(x)then
  47. o.Parent=x;
  48. end;
  49. return o;
  50. end;
  51. end;
  52. getPlace=function()
  53. if(find(workspace,'draw')==nil)then
  54. new('Model',workspace).Name='draw';
  55. end;
  56. if(find(workspace.draw,uname)==nil)then
  57. new('Model',workspace.draw).Name=uname;
  58. end;
  59. return workspace.draw[uname];
  60. end;
  61. drawLine=function(start,target)
  62. local gui=with'BlockMesh'{
  63. Parent=with'Part'{
  64. CFrame=CFrame.new(start,target)*CFrame.new(0,0,-(start-target).magnitude/2);
  65. Size=Vector3.new(drawPixel,drawPixel,(start-target).magnitude+.325*drawPixel);
  66. Parent=getPlace();
  67. Color=_G.drawColor;
  68. BottomSurface=0;
  69. Anchored=true;
  70. TopSurface=0;
  71. formFactor=3;
  72. Name=name;
  73. }}.Parent;
  74. table.insert(_G.mine,gui);
  75. return gui;
  76. end;
  77. onDown=function()
  78. if(drawing)then
  79. return nil;
  80. end;
  81. if(selectGui.Adornee)then
  82. destroy(selectGui.Adornee);
  83. end;
  84.  
  85. drawing=true;
  86.  
  87. mouse.Icon=iconOnDown;
  88. ver=ver+1;
  89.  
  90.  
  91. local cVer,start,target=ver,mouse.hit.p;
  92.  
  93. local group={};
  94. repeat
  95. Wait(0.02);
  96.  
  97. if(mouse.target and mouse.target.Name~=name and mouse.hit.p~=start)then
  98.  
  99. target=mouse.hit.p;
  100.  
  101. table.insert(group,drawLine(start,target));
  102.  
  103. start=target;
  104. end;
  105. until ver~=cVer;
  106. drawing=false;
  107.  
  108. local groupM=new('Model',getPlace());
  109. for i,v in next,group do
  110. if(v:IsDescendantOf(Workspace))then
  111. v.Parent=groupM;
  112. end;
  113. end;
  114. if(next(groupM:children())==nil)then
  115. destroy(groupM);
  116. end;
  117. end;
  118. onUp=function()
  119. mouse.Icon=iconNormal;
  120. ver=ver+1;
  121. end;
  122. onKeyDown=function(k)
  123. if(freeKeys[k]==false)then
  124. return false;
  125. end;
  126. freeKeys[k]=false;
  127. Wait(0.01);
  128. if(keyDowns[k])then
  129. keyDowns[k]();
  130. elseif(shortcuts[k])then
  131. shortcuts[k]();
  132. end;
  133. end;
  134. onKeyUp=function(k)
  135. freeKeys[k]=true;
  136. end;
  137. onMove=function()
  138.  
  139. end;
  140. onSelect=function(lmouse)
  141. frame.Visible=true;
  142.  
  143. mouse=lmouse;
  144.  
  145. mouse.Icon=iconNormal;
  146.  
  147. mouse.Button1Down:connect(onDown);
  148. mouse.KeyDown:connect(onKeyDown);
  149. mouse.Button1Up:connect(onUp);
  150. mouse.KeyUp:connect(onKeyUp);
  151. mouse.Move:connect(onMove);
  152. end;
  153. onDeselect=function()
  154. ver=ver+1;
  155. frame.Visible=false;
  156. selectGui.Adornee=nil;
  157. mouse.Icon=iconNormal;
  158. for i,v in next,freeKeys do
  159. freeKeys[i]=true;
  160. end;
  161. end;
  162. addButton=function(title,shortcut,fun)
  163. with'TextButton'{
  164. Text=string.format(' %s (%s)',title,shortcut);
  165. TextXAlignment=0;
  166. Parent=frame;
  167. }.MouseButton1Up:connect(fun);
  168.  
  169. shortcuts[shortcut]=fun;
  170.  
  171. local c=#frame:children();
  172. for i,v in next,frame:children()do
  173. v.Position=UDim2.new(0,0,0,20*(i-1));
  174. v.Size=UDim2.new(1,0,0,20);
  175. end;
  176.  
  177. frame.Position=UDim2.new(1,-152,.5,-c*10);
  178. frame.Size=UDim2.new(0,150,0,c*20);
  179. end;
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. for i,v in next,{guis;pack;}do
  189. pcall(function()
  190. repeat until destroy(v[name]);
  191. end);
  192. end;
  193.  
  194.  
  195.  
  196. tool=with'HopperBin'{
  197. Parent=pack;
  198. Name=name;
  199. };
  200. tool.Deselected:connect(onDeselect);
  201. tool.Selected:connect(onSelect);
  202.  
  203.  
  204.  
  205.  
  206. screen=with'ScreenGui'{
  207. Parent=guis;
  208. Name=name;
  209. };
  210. frame=with'Frame'{
  211. Parent=screen;
  212. Visible=false;
  213. };
  214. clframe=with'Frame'{
  215. Position=UDim2.new(.5,-50,.5,-50);
  216. Size=UDim2.new(0,100,0,100);
  217. Visible=false;
  218. Parent=screen;
  219. };
  220. selectGui=with'SelectionBox'{
  221. Parent=screen;
  222. };
  223.  
  224. local c=0;
  225. for y=0,7 do
  226. for x=0,7 do
  227. local color=BrickColor.palette(c).Color;
  228.  
  229. with'ImageButton'{
  230. Position=UDim2.new(.125*x,0,.125*y);
  231. Size=UDim2.new(.125,0,.125);
  232. BackgroundColor3=color;
  233. Parent=clframe;
  234. }.MouseButton1Up:connect(function()
  235. clframe.Visible=false;
  236. _G.drawColor=color;
  237. end);
  238.  
  239. c=c+1;
  240. end;
  241. end;
  242.  
  243. addButton('Color','c',function()
  244. clframe.Visible=true;
  245. end);
  246. addButton('Remove your draws','r',function()
  247. repeat
  248. destroy(_G.mine[1]);
  249. table.remove(_G.mine,1);
  250. Wait(0.01);
  251. until nil;
  252. end);
  253. addButton('Remove global draws','k',function()
  254. destroy(workspace.draw);
  255. while(_G.mine[1])do
  256. destroy(_G.mine[1]);
  257. table.remove(_G.mine,1);
  258. end;
  259. end);
  260. addButton('Remove selected','x',function()
  261. repeat
  262. if(find(workspace,'draw'))then
  263. local dt=mouse.target;
  264. if(dt and dt:IsDescendantOf(workspace.draw))then
  265. selectGui.Adornee=dt.Parent;
  266. else
  267. selectGui.Adornee=nil;
  268. end;
  269. else
  270. selectGui.Adornee=nil;
  271. end;
  272. Wait(0.01);
  273. until freeKeys.x;
  274. selectGui.Adornee=nil;
  275. end);
  276.  
  277.  
  278.  
  279.  
  280. repeat
  281. Wait(0.01);
  282. if(next(_G.mine)and _G.mine[_G.drawLimit])then
  283. destroy(_G.mine[1]);
  284. table.remove(_G.mine,1);
  285. end;
  286. until script.Parent==nil or tool.Parent==nil;
  287. script.Disabled=true;
  288. destroy(screen);
  289.  
  290.  
  291. --Dresmor Alakazard--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement