Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- COLOR="White"
- SIZE=0.25
- player = game:GetService('Players').LocalPlayer
- Debris = game:GetService("Debris")
- Http = game:GetService("HttpService")
- for i,v in pairs(player.PlayerGui:children())do
- if v:IsA'HandlesBase'then v:Destroy()end
- end
- MODELNAME="M DrawingParts "..player.Name
- partCount=0
- local ExistingModel = Workspace.Terrain:FindFirstChild (MODELNAME)
- if ExistingModel then
- print("Found existing model")
- for i,v in pairs(ExistingModel:children()) do
- if v:IsA'Part' then
- table.insert(partList,v)
- partCount=partCount+1
- end
- end
- Parts = ExistingModel
- else
- Parts = Instance.new("Model",Workspace.Terrain)
- Parts.Name=MODELNAME
- end
- c=CFrame.new
- a=function(x,y,z)return CFrame.Angles(x or 0,y or 0,z or 0)end
- IS=Instance.new
- bcol = BrickColor.new
- doAnchor=false
- pcall(function() player.Backpack.DrawFreely:Destroy() end) --Remove old tool
- Tool=Instance.new("Tool",player.Backpack)
- Tool.Name="DrawFreely"
- Tool.TextureId="http://www.roblox.com/asset/?id=53252159"
- Tool.CanBeDropped=false
- partParent=nil
- function P(x,y,z,col,tr)
- local part=Instance.new("Part",partParent)
- part.Size=Vector3.new(x,y,z)
- for i,v in pairs(Enum.NormalId:GetEnumItems())do --Easy way to set all surfaces to smooth.
- part[v.Name..'Surface']=10
- end
- part.Locked=true
- part.Transparency = tr or 0
- part.BrickColor=BrickColor.new(col or "")
- return part
- end
- function E(what)
- local tab={}
- if type(what) ~= "table" then
- table.insert(tab,what)
- else
- tab=what
- end
- return function(args)
- for i,object in pairs(tab) do
- for arg,value in pairs(args) do
- local argExists=(object[arg] ~= nil)
- if argExists then
- object[arg]=value
- end
- end
- end
- return what
- end
- end
- handle=P(.4,1,.4,'Black')
- handle.Parent=Tool
- handle.Name="Handle"
- function C(what)
- return function(bar)
- local obj=Instance.new(what)
- for arg,val in pairs(bar) do
- if arg == "_P" then
- obj.Parent = val
- else
- if obj[arg] then
- obj[arg]=val
- end
- end
- end
- return obj
- end
- end
- E(Instance.new("SpecialMesh",handle)){MeshId="http://www.roblox.com/asset/?id=100454579";
- TextureId="http://www.roblox.com/asset/?id=202074573";
- Scale=Vector3.new(1.5,1.5,1.5) }
- Active=false
- mouse = player:GetMouse()
- mouse.TargetFilter=Parts
- Undoing=false
- function spaceWord(text,spaces)
- local result=""
- for word in text:gmatch "%w+" do
- for pos,letter in word:gmatch "()(%w)" do
- if pos > 0 then
- result = result..string.rep(" ",(spaces or 1))..letter
- end
- end
- result = result..string.rep(" ",(spaces or 1))
- end
- return result
- end
- udim=function(a,b,c,d)
- if type(a)=='string'then
- x,y=tostring(a):match('(%d*%.*%d*),(%d*%.*%d*)')
- return UDim2.new(x or 0,x2 or 0,y or 0,y2 or 0)
- else
- return UDim2.new(a or 0,c or 0,b or 0,d or 0)
- end end
- pcall(function() player.PlayerGui.M_DrawingGui:Destroy() end)
- Gui=Instance.new("ScreenGui",player.PlayerGui)
- Gui.Name = "M_DrawingGui"
- function count_all_parts(obj2)
- local value=0
- local function recurse(obj)
- if obj:IsA'Part'then
- value=value+1
- end
- for _,v in pairs(obj:GetChildren()) do
- recurse(v)
- end
- end
- recurse(obj2)
- return value
- end
- do --gui
- mainFrame = E(IS("Frame",Gui)){
- Size = udim(0,0,200,200);
- Position = udim(0,.5);
- }
- topbar = E(IS("TextLabel",mainFrame)){
- Size=udim(1,.1);
- Text=spaceWord("Configuration",2);
- BackgroundTransparency=1;
- TextXAlignment="Center";
- BorderSizePixel=4;
- }
- othersFrame=E(IS("Frame",mainFrame)){
- Size=udim(1,.9);
- Position=udim(0,.1);
- }
- infobox = E(IS("Frame",othersFrame)){
- Size = udim(.3,.9);
- Position = udim(.65,.05);
- BorderSizePixel=0;
- }
- div = 1/4
- tab = {}
- frame = E(IS("Frame",infobox)){
- Size = udim(1,div);
- }
- lab = E(IS("TextLabel",frame)){
- Size = udim(.5,1);
- Text = "Parts";
- TextScaled=true;
- BackgroundTransparency=1;
- }
- partCount = count_all_parts(Parts)
- partcountLab = E(IS("TextLabel",frame)){
- Size = udim(.5,1); Position = udim(.5,0);
- Text = partCount;
- BackgroundTransparency=1;
- TextXAlignment = "Right";
- }
- frame = E(IS("Frame",infobox)){
- Size = udim(1,div);
- Position = udim(0,div*2);
- }
- lab = E(IS("TextLabel",frame)){
- Size = udim(.5,1);
- Text = "Color";
- TextScaled=true;
- BackgroundTransparency=1;
- }
- colorLab = E(IS("Frame",frame)){
- Size=udim(.5,1);Position=udim(.5,0);
- BackgroundColor=BrickColor.new(COLOR);
- BorderSizePixel=0;
- }
- frame = E(IS("Frame",infobox)){
- Size = udim(1,div);
- Position = udim(0,.7);
- }
- lab = E(IS("TextLabel",frame)){
- Size = udim(.5,1);
- Text = "Size";
- TextScaled=true;
- BackgroundTransparency=1;
- }
- sizeBox=E(IS("TextBox",frame)){
- Size = udim(.45,1);Position = udim(.5,0);
- BackgroundTransparency = 1;
- Text = SIZE;
- TextScaled = true;
- }
- frame = E(IS("Frame",infobox)){
- Size = udim(1,.1);
- Position = udim(0,1/5*4);
- }
- lab = E(IS("TextLabel",frame)){
- Size = udim(.5,1);
- Text = "Lock Y movement on drag";
- TextScaled=true;
- BackgroundTransparency=1;
- }
- checkBox=E(IS("TextButton",frame)){
- Size = udim(.45,1);Position = udim(.5,0);
- BackgroundTransparency = 1;
- Text = "X";
- TextScaled = true;
- }
- div = 1/#infobox:children()
- for i,v in pairs(infobox:children()) do
- v.Size = udim(1,div)
- v.Position = udim(0,(-1+i)*div)
- end
- checkBox.MouseButton1Click:connect(function()
- lock_y_movement = not lock_y_movement
- if lock_y_movement then
- checkBox.Text = "X"
- else
- checkBox.Text = ""
- end
- end)
- sizeBox.FocusLost:connect(function()
- SIZE=tonumber(sizeBox.Text)
- end)
- onFor,onBak=function()
- SIZE=SIZE+.1
- sizeBox.Text=SIZE
- end,function()
- SIZE=SIZE-.1
- sizeBox.Text=SIZE
- end
- sizeBox.MouseWheelForward:connect(onFor)
- sizeBox.MouseWheelBackward:connect(onBak)
- lab.MouseWheelForward:connect(onFor)
- lab.MouseWheelBackward:connect(onBak)
- colorFrame=E(IS("Frame",othersFrame)){
- Size=udim(.6,1);
- }
- --Color Palette
- for x = 0,7 do
- for y = 0,7 do
- local but=E(IS("TextButton",colorFrame)){
- Size = udim(1/8,1/8);
- Position = udim(1/8*x,1/8*y);
- Text = '';
- BackgroundColor = BrickColor.palette(x+y*8);
- }
- but.MouseButton1Click:connect(function()
- COLOR=but.BackgroundColor.Name
- colorLab.BackgroundColor = but.BackgroundColor
- end)
- end
- end
- for i,v in pairs(mainFrame:children()) do
- v.BorderSizePixel=0;
- end
- end
- do --gui2
- local prev_frame_pos = mainFrame.Position
- local prev_frame_size = mainFrame.AbsoluteSize
- local mainFrame = C'Frame'{_P=Gui;
- Size = udim(0,0,100,200);
- Position = prev_frame_pos + udim(0,0,prev_frame_size.x/2+100)
- }
- local topBar = C'TextLabel'{_P=mainFrame;
- Size=udim'1,.1';
- Text = spaceWord("Layers", 4);
- }
- local layerFrame = C'Frame'{_P=mainFrame;
- Size = udim'1,.9';
- Position = udim'0,.1';
- }
- local add_button = C'TextButton'{_P=mainFrame;
- Text='+';
- FontSize=10;
- Size=udim'.3,.1';
- Position = udim'.7,.9';
- BackgroundColor = bcol'Mint';
- }
- Selected_layer = 0
- Layers = {}
- max_layers = 10
- layer_height = 1/max_layers
- layer_bg_col = bcol"White"
- local h,s,v = Color3.toHSV(layer_bg_col.Color)
- highlight_col = bcol(Color3.fromHSV(h,s,v-.15))
- h,s,v = nil,nil,nil
- function getLayers()
- local res = {}
- for i,v in pairs(Parts:children()) do
- if v:IsA'Model' then
- table.insert(res,v)
- end
- end
- return res
- end
- layer_position = 0
- prev_click_t=tick()
- function update_layers()
- layerFrame:ClearAllChildren()
- for i,layer in pairs(getLayers()) do
- layer.Position.Value = i
- local layer_frame = C'Frame'{_P = layerFrame;
- Size = udim(1,layer_height);
- Position = udim(0,(-1+i)*layer_height);
- }
- local remove_button = C'TextButton'{_P=layer_frame;
- Size = udim'.2,1';
- Text = 'X';
- BackgroundColor = bcol'Bright red';
- TextScaled= true;
- }
- local hide_button = C'TextButton'{_P=layer_frame;
- Size = udim'.2,1';
- Position = udim'.2,0';
- Text = 'H';
- TextScaled = true;
- Name = 'Hidebutton'
- }
- local name_box = C'TextButton'{_P=layer_frame;
- Size = udim'.6,1';
- Position = udim'.4,0';
- Text = layer.Name;
- TextScaled=true;
- BackgroundColor = layer_bg_col;
- AutoButtonColor = false;
- }
- layer.name_box.Value = name_box
- hideLayer(layer,true)
- -- print(layer.Visible.Value)
- if layer.Selected.Value == true then
- name_box.BackgroundColor = highlight_col
- else
- name_box.BackgroundColor = layer_bg_col
- end
- -- for i,v in pairs(layer:children())do
- -- if v:IsA'Part'then
- remove_button.MouseButton1Down:connect(function()
- removeLayer(layer)
- end)
- hide_button.MouseButton1Down:connect(function()
- hideLayer(layer)
- end)
- name_box.MouseButton2Down:connect(function()
- popupRenameWindow(layer)
- end)
- name_box.MouseButton1Down:connect(function()
- select_layer(layer)
- end)
- end
- end
- function mergeLayer(layer)
- local prev_layer = getLayers()[layer.Position.Value-1] --previous layer
- if not prev_layer then warn("Cant do merging") return end
- local part_t = {} --collect parts to this
- for i,v in pairs(layer:children()) do
- if v:IsA'Part'then
- table.insert(part_t,v)
- end
- end
- for _,v in pairs(part_t) do
- v.Parent = prev_layer
- end
- removeLayer(layer)
- update_layers()
- end
- function cloneLayer(layer)
- local cl=layer:Clone()
- cl.Parent=Parts
- cl.Name = layer.Name..'_cl'
- cl.Position.Value = #getLayers()
- update_layers()
- select_layer(cl)
- end
- function removeLayer(layer)
- if #getLayers() == 0 then return end
- local pos1 = layer.Position.Value
- local pos2 = Selected_Layer.Position.Value
- local fou=getLayers()[pos1-1]
- layer:Destroy()
- update_layers()
- if pos1 == pos2 and getLayers()[pos2-1] then
- select_layer(getLayers()[pos2-1])
- elseif pos1 == pos2 and pos2 == 1 then
- select_layer(getLayers()[#getLayers()])
- end
- end
- function hideLayer(layer,se)
- if not layer:FindFirstChild'name_box' then return end
- local back = layer.name_box.Value.Parent:FindFirstChild'Hidebutton'
- if not se then
- layer.Visible.Value = not layer.Visible.Value
- end
- if layer.Visible.Value == true then
- for i,v in pairs(layer:children()) do
- if v:IsA'Part' then
- v.Transparency = 0
- end
- end
- -- layer.name_box.Value.Text = layer.Name
- back.BackgroundColor=bcol'White'
- elseif layer.Visible.Value == false then
- for i,v in pairs(layer:children()) do
- if v:IsA'Part' then
- v.Transparency = 1
- end
- end
- -- layer.name_box.Value.Text = layer.Name.." (h)"
- back.BackgroundColor = bcol'Mint'
- end
- end
- lock_y_movement = true
- function moveLayer(layer,mouse)
- Moving = true
- local layerframe = layer:GetModelCFrame()
- local y = layerframe.Y
- while Moving do
- local poos = Vector3.new(mouse.hit.p.x,y,mouse.hit.p.z)
- poos = (lock_y_movement and poos or mouse.hit.p)
- layer:TranslateBy((layer:GetModelCFrame().p-poos)*-1)
- wait()
- end
- end
- do ---PRECISE MOVEMENT
- handle_part = nil
- local handle = nil
- function preciseMove(layer,mouse)
- if not handle_part then
- handle_part = P(1,1,1,'Black',1)
- local layer_size = layer:GetExtentsSize()
- -- E{handle_part}{Anchored = true; CanCollide = false;
- -- Size = layer_size;}
- handle_part.Anchored = true
- handle_part.CanCollide = false
- -- handle_part.Size = layer_size
- handle_part.CFrame = CFrame.new(layer:GetModelCFrame().p)
- handle_part.Parent = Workspace
- handle = C'Handles'{
- Style = Enum.HandlesStyle.Movement;
- }
- handle.Faces = Faces.new(Enum.NormalId.Top,Enum.NormalId.Right,
- Enum.NormalId.Front)
- -- Enum.NormalId.Bottom,Enum.NormalId.Back,Enum.NormalId.Left)
- handle.Adornee = handle_part
- handle.Parent = player.PlayerGui
- local previous,fake_handle_part
- handle.MouseButton1Down:connect(function()
- previous = handle_part.CFrame
- fake_handle_part = handle_part:Clone()
- fake_handle_part.Parent=Workspace
- -- handle.Adornee = fake_handle_part
- end)
- local snap = 1
- handle.MouseDrag:connect(function(face,drag_distance)
- local difference = drag_distance % snap
- local lower_deg = drag_distance - difference
- local upper_deg = drag_distance - difference + snap
- local lower_deg_prox = math.abs(drag_distance - lower_deg)
- local upper_deg_prox = math.abs(drag_distance - upper_deg)
- if lower_deg_prox <= upper_deg_prox then
- drag_distance = lower_deg
- else
- drag_distance = upper_deg
- end
- local increase = drag_distance;
- local cf
- --main thingy--
- if face == Enum.NormalId.Top then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(0,increase,0) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- elseif face == Enum.NormalId.Bottom then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(0,-increase,0) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- elseif face == Enum.NormalId.Right then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(increase,0,0) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- elseif face == Enum.NormalId.Left then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(-increase,0,0) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- elseif face == Enum.NormalId.Front then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(0,0,-increase) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- elseif face == Enum.NormalId.Back then
- cf = CFrame.new(previous.p):toWorldSpace(
- CFrame.new(0,0,increase) * CFrame.Angles (previous:toEulerAnglesXYZ() ) )
- end
- layer:TranslateBy( (layer:GetModelCFrame().p - cf.p)*-1 )
- handle_part.CFrame = c(layer:GetModelCFrame().p)
- end)
- else
- handle_part:Destroy()
- handle:Destroy()
- handle_part = nil
- handle = nil
- end
- end
- end
- resize_handle=nil
- function resizeLayer(layer)
- if not resize_handle then
- local nearest={p=nil,m=math.huge}
- for i,v in pairs(layer:children()) do --Get Nearest Part to torso
- if v:IsA'Part'then
- if (v.Position-torso.Position).magnitude < nearest.m then
- nearest.m = (v.Position-torso.Position).magnitude
- nearest.p=v
- end
- end
- end
- if not nearest.p then return end
- resize_handle = C'Handles'{
- Style = Enum.HandlesStyle.Resize;
- Adornee = nearest.p;
- Faces = Faces.new(Enum.NormalId.Right,Enum.NormalId.Left,
- Enum.NormalId.Front,Enum.NormalId.Back);
- }
- resize_handle.Style = Enum.HandlesStyle.Resize
- resize_handle.Adornee = nearest.p;
- resize_handle.Parent=player.PlayerGui
- local snap = .1
- local previous
- local previous_cframes
- resize_handle.MouseButton1Down:connect(function()
- previous = nearest.p.Size.x
- previous_cframes = {}
- for i,v in pairs(layer:children())do
- if v:IsA'Part'then
- local t={v,v.CFrame,v.Size}
- table.insert(previous_cframes,t)
- end
- end
- end)
- resize_handle.MouseDrag:connect(function(face,drag_dist)
- -- print(previous_cframes)
- local diff = drag_dist % snap
- local low_deg = drag_dist-diff
- local up_deg = drag_dist-diff + snap
- local low_deg_prox=math.abs(drag_dist-low_deg)
- local up_deg_prox=math.abs(drag_dist-up_deg)
- if low_deg_prox >= up_deg_prox then
- drag_dist=low_deg
- else
- drag_dist=up_deg
- end
- local increase = drag_dist
- if face == Enum.NormalId.Left then
- local size_increase = Vector3.new(increase,0,0)
- for i,v in pairs(previous_cframes)do
- v[1].Size = v[3]+size_increase
- if v[1].Size == v[3]+size_increase then
- v[1].CFrame=v[2]:toWorldSpace(CFrame.new(-increase/2,0,0) )
- else
- v[1].Size = v[3]
- v[1].CFrame=v[2]
- end
- end
- elseif face == Enum.NormalId.Right then
- local size_increase = Vector3.new(increase,0,0)
- for i,v in pairs(previous_cframes)do
- v[1].Size = v[3]+size_increase
- if v[1].Size == v[3]+size_increase then
- v[1].CFrame=v[2]:toWorldSpace(CFrame.new(increase/2,0,0) )
- else
- v[1].Size = v[3]
- v[1].CFrame=v[2]
- end
- end
- end
- if face == Enum.NormalId.Front then
- local size_increase = Vector3.new(0,0,increase)
- for i,v in pairs(previous_cframes)do
- v[1].Size = v[3]+size_increase
- if v[1].Size == v[3]+size_increase then
- v[1].CFrame=v[2]:toWorldSpace(CFrame.new(0,0,-increase/2) )
- else
- v[1].Size = v[3]
- v[1].CFrame=v[2]
- end
- end
- elseif face == Enum.NormalId.Back then
- local size_increase = Vector3.new(0,0,increase)
- for i,v in pairs(previous_cframes)do
- v[1].Size = v[3]+size_increase
- if v[1].Size == v[3]+size_increase then
- v[1].CFrame=v[2]:toWorldSpace(CFrame.new(0,0,increase/2) )
- else
- v[1].Size = v[3]
- v[1].CFrame=v[2]
- end
- end
- end
- end)
- else
- resize_handle:Destroy()
- resize_handle=nil
- end
- end
- archdl = nil
- hp = nil
- prima = nil
- function rotateLayer(layer)
- if not archdl then
- local center = layer:GetModelCFrame()
- local p=P(1,1,1,'',1)p.Anchored=true
- prima = p
- p.Parent = Workspace
- p.Size = layer:GetExtentsSize()/2
- p.CFrame=CFrame.new(center.p)
- archdl = Instance.new("ArcHandles")
- archdl.Axes = Axes.new(Enum.Axis.X,Enum.Axis.Y,Enum.Axis.Z)
- archdl.Adornee = p
- archdl.Parent = player.PlayerGui
- layer.PrimaryPart = p
- previous = p.CFrame
- archdl.MouseButton1Down:connect(function()
- previous = p.CFrame
- end)
- snap=15
- archdl.MouseDrag:connect(function(axis,drag_distance,d_rad)
- --format angle for easier using
- local drag_distance = math.floor(math.deg(drag_distance))
- local difference = drag_distance % snap
- local lower_deg = drag_distance - difference
- local upper_deg = drag_distance - difference + snap
- local lower_deg_prox = math.abs(drag_distance - lower_deg)
- local upper_deg_prox = math.abs(drag_distance - upper_deg)
- if lower_deg_prox <= upper_deg_prox then
- drag_distance = lower_deg
- else
- drag_distance = upper_deg
- end
- local increase = snap * math.floor(drag_distance/snap)
- local final_cf = CFrame.new()
- if axis == Enum.Axis.Y then
- final_cf = previous:toWorldSpace(CFrame.new(0,0,0)*a(0,math.rad(increase)) )
- elseif axis == Enum.Axis.X then
- final_cf = previous:toWorldSpace(CFrame.new(0,0,0)*a(math.rad(increase)) )
- elseif axis == Enum.Axis.Z then
- final_cf = previous:toWorldSpace(CFrame.new(0,0,0)*a(0,0,math.rad(increase)) )
- end
- if layer.PrimaryPart then
- layer:SetPrimaryPartCFrame(final_cf)
- end
- -- local axisangle = Vector3.FromAxis(axis)
- -- axisangle = axisangle * relativeAngle
- -- p.CFrame = previous * a(axisangle.X,axisangle.Y,axisangle.Z)
- -- local rx,ry,rz = p.CFrame:toEulerAnglesXYZ()
- -- p.CFrame = previous * a(x,y,z)
- end)
- else
- if archdl.Adornee then archdl.Adornee:Destroy() end
- archdl:Destroy()
- prima:Destroy()
- layer.PrimaryPart = nil
- archdl = nil
- prima = nil
- end
- end
- Selected_Layer = nil
- old_selected = nil
- function select_layer(layer)
- for i,v in pairs(getLayers()) do --"Deselect all boxes"
- if v:FindFirstChild'name_box' then
- v.Selected.Value = false
- -- v.name_box.Value.BackgroundColor = layer_bg_col
- end
- end
- local curcam = Workspace.CurrentCamera
- Spawn(function()
- if layer then
- local size = layer:GetExtentsSize()
- local p = P(size.x,size.y,size.z,'White',.9)p.Parent = curcam
- p.Material ='Neon'
- p.Transparency = .99
- p.Anchored=true
- p.CanCollide=false
- p.CFrame=layer:GetModelCFrame()
- wait'.15'
- p:Destroy()
- end
- end)
- if layer then
- Selected_Layer = layer
- Selected_Layer.Selected.Value = true
- end
- -- Selected_Layer.name_box.Value.BackgroundColor = highlight_col
- update_layers()
- end
- function emptyLayer(layer)
- for i,v in pairs(layer:children()) do
- if v:IsA'Part'then
- v:Destroy()
- end
- end
- end
- function makeLayer(Name)
- local default_name = "Layer "..tonumber(#getLayers())
- local Layer = C'Model'{_P = Parts; Name = Name or default_name}
- local vis_bool = C'BoolValue'{_P = Layer; Name = 'Visible';}
- local name_box = C'ObjectValue'{_P = Layer; Name = 'name_box';}
- local selected = C'BoolValue'{_P=Layer; Name = "Selected"; Value = false}
- local layer_pos = C'NumberValue'{_P=Layer;Name="Position"; Value = 0}
- vis_bool.Value = true
- update_layers()
- select_layer(Layer)
- end
- if #getLayers() < 1 then --Create first layer if does not exist
- makeLayer("Base")
- else
- select_layer(getLayers()[1])
- end
- add_button.MouseButton1Down:connect(function()
- makeLayer("Layer "..tostring(#getLayers()+ 1))
- end)
- end
- do --gui3
- function popupRenameWindow(layer)
- shift_down = false
- local layer_box = layer.name_box.Value
- local layer_frame = layer_box.Parent
- if not Selected_Layer then return end
- abs_pos = layer_frame.AbsolutePosition
- abs_size = layer_frame.AbsoluteSize
- local inputbox = C'TextBox'{_P=layer_frame;
- Size=udim'.5,.5';
- Position=udim'1,.5';
- Text=Selected_Layer.Name;
- ClearTextOnFocus = false;
- BackgroundColor = layer_bg_col;
- }
- inputbox:CaptureFocus()
- inputbox.FocusLost:wait()
- inputbox:ReleaseFocus()
- wait()
- local text = inputbox.Text
- inputbox:Destroy()
- layer.Name = text
- update_layers()
- end
- end
- Shooting=false
- function shoot()
- local torso = Tool.Parent:FindFirstChild 'Torso'
- if not torso then return end
- Shooting=true
- while Shooting do
- for i=-88,88,88 do
- local cl=handle:Clone() cl.Parent=Tool
- E(cl){CanCollide=true; Name='Bullet'}
- cl.CFrame=( (handle.CFrame*a(0,i)) *c(0,0,-.5))*a(math.pi/2)
- E(IS("BodyVelocity",cl)){
- velocity = (cl.CFrame*a(-math.pi/2)).lookVector*30
- }
- E(IS("BodyGyro",cl)){
- cframe=cl.CFrame;}
- local connection
- connection = cl.Touched:connect(function(hit)
- -- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- -- if player and player ~= game.Players.mugex then player:Kick("Ya was on mah drawing") end
- if hit:IsDescendantOf(Tool.Parent) then return end
- connection:disconnect()
- local w=Instance.new("Weld",cl)
- w.Part0 = cl;
- w.Part1 = hit;
- w.C0 = c();
- w.C1 = hit.CFrame:toObjectSpace(cl.CFrame);
- end)
- game:GetService("Debris"):AddItem(cl,3)
- end
- wait(.1)
- end
- end
- shift_down = false
- function upKey()
- if not Selected_Layer then return end
- local pos = Selected_Layer.Position.Value
- if shift_down then
- if getLayers()[pos -1] then
- select_layer(getLayers()[pos - 1])
- else
- select_layer(getLayers()[#getLayers()])
- end
- else
- if getLayers()[pos +1] then
- select_layer(getLayers()[pos + 1])
- else
- if getLayers()[1]then
- select_layer(getLayers()[1])
- end
- end
- end
- end
- local lib=LoadLibrary("RbxGui")
- iser=game:GetService("InsertService")
- itemsPerRow=5
- itemsPerColumn=5
- symbols={1,2,3,4,5,6,6,7,34,3,4,5,3,5,3,5}
- for i,v in pairs(getLayers()) do
- if v.Selected.Value == true then
- select_layer(v)
- end
- end
- function iter(a)
- for i,v in pairs(a:GetChildren())do
- if v:IsA'BodyMover'then
- v:Destroy()
- else
- iter(v)
- end
- end
- end
- function filter(tab, what)
- local res_tab = {}
- for i,v in pairs(tab) do
- if type(v) == 'userdata' and v:IsA(what) then
- table.insert(res_tab,v)
- end
- end
- return res_tab
- end
- function getActiveLayer(what)
- local res
- for i,v in pairs(what:children())do
- if v:IsA'Folder' then
- local val = v:FindFirstChild'Selected'
- if val and val.Value == true then
- res = v
- end
- end
- end
- end
- Erasing=false
- function eraser(mouse)
- Erasing=true
- local eraser_part = P(2.5,2.5,2.5,'White',.9)
- eraser_part.Shape=0
- eraser_part.Anchored=true
- eraser_part.CanCollide=false
- eraser_part.Parent=Workspace.CurrentCamera
- mouse.TargetFilter = eraser_part
- -- local sphere = C'SelectionSphere'{
- -- Adornee = eraser_part;
- -- }
- -- sphere.Parent=player.PlayerGui;
- while Erasing do
- if eraser_part and eraser_part.Parent~=nil then
- if mouse.Target ~= eraser_part then
- eraser_part.CFrame=mouse.hit
- end
- end
- local f1 = Selected_Layer
- if f1 then
- for i,v in pairs(f1:children())do
- if v:IsA'Part' then
- if mouse.Target == v then v:Destroy()end
- local m=(v.Position-mouse.hit.p).magnitude
- if m < 2.5 then
- v:Destroy()
- end
- end
- end
- end
- wait()
- end
- eraser_part:Destroy() --sphere:Destroy()
- end
- function Undo()
- if not Selected_Layer then warn("No layer selected") return end
- local Parts = filter(Selected_Layer:children(),'Part')
- while Undoing and Parts ~= nil do
- Parts = filter(Selected_Layer:children(),'Part')
- lastPart=#Parts
- if Parts[lastPart] ~= nil then
- Parts[lastPart]:Destroy()
- end
- wait()
- end
- end
- Keys={
- UndoKey = "f";
- RotateKey = "r";
- RemoveKey = "c";
- ShootKey = "b";
- FreeKey = "v";
- EraserKey = "e";
- NewlayerKey = "n";
- Upkey = "q";
- Deletekey = "x";
- Hidekey = "h";
- Mergekey = "m";
- Movekey = "g";
- Rotatekey = "r";
- ResizeKey = "t";
- GuiKey = "z";
- }
- Moving = false
- function onEquip(mouse)
- mouse.KeyUp:connect(function(key) --OnRelease
- if key == '0' then
- shift_down = false
- end
- if key == Keys.UndoKey then
- Undoing = false
- elseif key == Keys.ShootKey then
- Shooting=false
- elseif key == Keys.EraserKey then
- Erasing=false
- elseif key == Keys.NewlayerKey then
- makeLayer()
- elseif key == Keys.Movekey then
- Moving = false
- end
- end)
- mouse.KeyDown:connect(function(key)
- if key == '0' then
- shift_down = true
- end
- if key == Keys.UndoKey then
- Undoing=true
- Undo()
- elseif key == Keys.RemoveKey then
- if shift_down then
- cloneLayer(Selected_Layer)
- else
- emptyLayer(Selected_Layer)
- end
- elseif key == Keys.GuiKey then
- if Gui.Parent == Tool then
- Gui.Parent = player.PlayerGui
- else
- Gui.Parent = Tool
- end
- elseif key == Keys.ResizeKey then
- resizeLayer(Selected_Layer)
- elseif key == Keys.FreeKey then
- iter(player.Character)
- elseif key == Keys.EraserKey then
- eraser(mouse)
- elseif key == Keys.Upkey then
- upKey()
- elseif key == Keys.Deletekey then
- if Selected_Layer then
- removeLayer(Selected_Layer)
- end
- elseif key == Keys.Hidekey then
- hideLayer(Selected_Layer)
- elseif key == Keys.Mergekey then
- mergeLayer(Selected_Layer)
- elseif key == Keys.Movekey then
- if shift_down then
- preciseMove(Selected_Layer)
- else
- Moving = true
- moveLayer(Selected_Layer,mouse)
- end
- elseif key == Keys.ShootKey then
- shoot()
- elseif key == Keys.Rotatekey then
- if Selected_Layer then
- if shift_down then
- popupRenameWindow(Selected_Layer)
- else
- rotateLayer(Selected_Layer)
- end
- end
- end
- end)
- end
- function Draw()
- local sel_part = mouse.Target
- -- local Y = sel_part.p.y
- if not Selected_Layer then warn("No Selected Layer") return end
- Active=true
- previousPoint=mouse.hit.p
- currentPoint=previousPoint
- -- p=nil
- linemode=false
- if shift_down then linemode = true
- local magnitude=(previousPoint-currentPoint).magnitude
- p=P(SIZE,.1,magnitude,COLOR)p.Name='Ink'
- p.Parent=Selected_Layer
- Instance.new("BlockMesh",p).Scale = Vector3.new(1,.1,1)
- p.Anchored=true
- p.CFrame=(c(previousPoint,currentPoint)*c(0,0,-magnitude/2))
- end
- partParent=nil
- while Active and Parts ~= nil and (Parts.Parent ~= nil) do
- if mouse.Target ~= nil then
- -- if mouse.Target ~= sel_part then
- -- mouse.TargetFilter = mouse.Target
- -- end
- if linemode then
- currentPoint = mouse.hit.p
- local magnitude=(previousPoint-currentPoint).magnitude
- p.Size = Vector3.new(SIZE,.1,magnitude)
- p.CFrame=(c(previousPoint,currentPoint)*c(0,0,-magnitude/2))
- -- previousPoint=currentPoint
- else
- local isClose=false
- local currentPoint=mouse.hit.p
- -- if #Parts:children() > 0 then
- for i,part in pairs(Parts:children()) do
- local magnitude = (currentPoint-previousPoint).magnitude
- if magnitude < SIZE*.9 then
- isClose=true
- end
- end --end
- if not isClose and not mouse.Target.Name~='Ink' then
- local magnitude=(previousPoint-currentPoint).magnitude
- local p=P(SIZE,.1,magnitude,COLOR)p.Name='Ink'
- p.Parent=Selected_Layer
- Instance.new("BlockMesh",p).Scale = Vector3.new(1,.1,1)
- p.Material=(Nightmode and 'Neon' or 'SmoothPlastic')
- p.Anchored=true
- p.CFrame=(c(previousPoint,currentPoint)*c(0,0,-magnitude/2))
- previousPoint=currentPoint
- end
- end
- end
- wait()
- end
- end
- Nightmode = false
- onChange=function()
- if Parts and Parts.Parent~= nil then
- local count = count_all_parts(Parts)
- partcountLab.Text=tostring(count)
- end
- end
- Parts.ChildAdded:connect(onChange)
- Parts.ChildRemoved:connect(onChange)
- Tool.Equipped:connect(onEquip)
- Tool.Deactivated:connect(function() Active=false
- end)
- Tool.Activated:connect(Draw)
Add Comment
Please, Sign In to add comment