Advertisement
Guest User

DrawScript

a guest
May 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.79 KB | None | 0 0
  1. ply=game:service'Players'.LocalPlayer
  2.  
  3. repeat wait()until ply~=nil
  4.  
  5. char=ply.Character
  6. torso=char.Torso
  7.  
  8. bcol=BrickColor.new
  9. cfn,md,mr,v3n=CFrame.new,math.rad,math.random,Vector3.new
  10. ang=function(x,y,z)return CFrame.Angles(x or 0,y or 0,z or 0)end
  11. Debris=game:service'Debris'
  12. m={}
  13. m.tau=math.pi*2
  14. m.floatforce = 196.25
  15.  
  16. hum_root=char.HumanoidRootPart
  17.  
  18. mouse=ply:GetMouse()
  19.  
  20. function l(a,x,y,z,xx,yy,zz)
  21.     if string.find(tostring(a),',') == nil then
  22.     return (a.CFrame*CFrame.new(x or 0,y or 0,z or 0))*CFrame.Angles(xx or 0,yy or 0, zz or 0)
  23.     else return (a * CFrame.new(x or 0,y or 0,z or 0))*CFrame.Angles(xx or 0,yy or 0,zz or 0)
  24.     end
  25. end
  26.  
  27. pcall(function() char.Stick:Destroy() end) --- Destroys Physical Tool
  28. Weapon = Instance.new("Model",char) Weapon.Name = 'Stick'
  29. Instance.new('BoolValue',Weapon).Name='Mug_Did'
  30. do --UTILITIES
  31.  
  32. function Create(ClassName)
  33.     local obj=Instance.new(ClassName)
  34.     return function(props)
  35.         obj.Parent=Weapon
  36.         for key,val in pairs(props)do
  37.             if key=='_P'then
  38.                 obj['Parent']=val
  39.             elseif i=='_C'then
  40.                 obj[val[1]]:connect(val[2])
  41.             else
  42.                 obj[key]=val
  43.             end
  44.         end
  45.         return obj
  46.     end
  47. end
  48.  
  49. do --CREATION
  50.  
  51. Cur_Parent=nil
  52. current_mat=nil
  53. anchor=false
  54. Part = function(x,y,z,color,tr,cc,an,parent)
  55.         local p = Instance.new('Part',parent or Cur_Parent or Weapon)
  56.         p.formFactor = 'Custom'
  57.         p.Locked = true
  58.         p.Position=torso.Position
  59.         p.Size = Vector3.new(x,y,z)
  60.         p.BrickColor = BrickColor.new(color or 'White')
  61.         p.CanCollide = cc or false
  62.         p.Anchored = an or anchor or false
  63.         p.Transparency = tr or 0
  64.         p.Material=current_mat or'SmoothPlastic'
  65.         for i,v in pairs{'TopSurface','BottomSurface','FrontSurface','BackSurface','LeftSurface','RightSurface'}do
  66.                 p[v]=10
  67.         end
  68.         return p
  69. end
  70.  
  71. Meshes = {Diamond='9756362';Spikeball='9982590';Table='111868131';
  72. Egg='1527559';Ring='3270017';Bullet='2697549';Grass='1080954';
  73. Shark='82821384';Sword='12221720';Crown='10688643';Spike='1033714';
  74. Leaf='48100239';Fist='65322375';Chakram='19251107';Crown='20329976';Spring='9753878';
  75. Tree='8564125';Fireball='10587413';DiamondBall='10917418'}
  76.  
  77. Textures = {Leaf='rbxassetid://48047287';White='rbxassetid://5736319'}
  78.  
  79. Mesh = function(par,num,x,y,z,tex)
  80.         local msh = _
  81.         if num == 1 then msh = Instance.new("CylinderMesh",par)
  82.         elseif num == 2 then msh = Instance.new("SpecialMesh",par) msh.MeshType = 3
  83.         elseif num == 3 then msh = Instance.new("SpecialMesh",par) msh.MeshType = 6
  84.         elseif num == 4 then msh = Instance.new("SpecialMesh",par) msh.MeshType = 'Wedge'
  85.         elseif type(num) == 'string' then msh = Instance.new("SpecialMesh",par)
  86.             if num=='Torso'then msh.MeshType=1 else
  87.         msh.MeshId = string.find(num,'://') == nil and 'rbxassetid://'..Meshes[num] or num end
  88.         end
  89.         msh.Scale = Vector3.new(x or 1,y or 1,z or 1)
  90.         if tex then
  91.             msh.TextureId = Textures[tex] or tex or ''
  92.         end
  93.         return msh
  94. end
  95.  
  96. end
  97.  
  98.  
  99. function tag(a,b)
  100.     if type(b)=='string'then
  101.         if not getfenv()[b]then
  102.             getfenv()[b]={}
  103.         end
  104.         table.insert(getfenv()[b],a)
  105.     else
  106.         table.insert(b,a)
  107.     end
  108. end
  109. pcall(function()ply.Backpack.DrawTool:Destroy()end)
  110. local hop=Create'HopperBin'{_P=ply.Backpack;Name='DrawTool'}
  111.  
  112. history={}
  113.  
  114. function onDown()
  115.     holding=true
  116.     st_pos=mouse.hit
  117.     prev=st_pos
  118.     local delta=0
  119.     while holding do
  120.         if delta>.001 then
  121.             local mag=(prev.p-mouse.hit.p).magnitude
  122.             local pp=Part(.1,.1,mag)pp.Anchored=true
  123.             pp.CFrame=cfn(mouse.hit.p,prev.p)*cfn(0,0,-mag/2)
  124.             table.insert(history,pp)
  125.         end
  126.         delta=(mouse.hit.p-prev.p).magnitude
  127.         prev=mouse.hit
  128.         wait()
  129.     end
  130. end
  131. holding2=false
  132. function onUp()holding=false end
  133.  
  134. function eraser()
  135.     holding2=true
  136.     while holding2 do
  137.         for i,v in pairs(history)do
  138.             if (v.Position-mouse.hit.p).magnitude < 3 then
  139.                 v:Destroy() table.remove(history,i)
  140.             end
  141.         end
  142.         wait(.05)
  143.     end
  144. end
  145.  
  146.  
  147. hop.Selected:connect(function(mouse)
  148.     mouse.Button1Up:connect(onUp)
  149.     mouse.KeyUp:connect(function(f)if f=='f'or f=='e'then holding2=false end  end)
  150.     mouse.KeyDown:connect(function(f)if f=='f'then
  151.         holding2=true
  152.         while holding2 do
  153.             if history[#history]then
  154.             history[#history]:Destroy()table.remove(history,#history)
  155.             end
  156.             wait()
  157.         end
  158.         elseif f=='e'then eraser()
  159.     end
  160.     end)
  161.     mouse.Button1Down:connect(onDown)
  162.    
  163. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement