Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(4)
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local us = game:GetService("UserInputService")
- local lastline = nil
- local lastpart = nil
- local lastpart2 = nil
- local folder = workspace:FindFirstChild("DRAWDING")
- if folder == nil then
- folder = Instance.new("Folder",workspace)
- folder.Name = "DRAWDING"
- end
- local drawing = false
- local remote = player:WaitForChild("lud")
- local pensize = 3
- local distance = 1.5
- local color = Color3.fromRGB(145,145,145)
- --
- folder.Name = "DrawStuff"
- mouse.TargetFilter = folder
- function subtractcf(a, b)
- local x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33 = a:components()
- return CFrame.new(x - b.x, y - b.y, z - b.z, m11, m12, m13, m21, m22, m23, m31, m32, m33);
- end
- local function multiplyCFrame(a, b)
- local ax, ay, az, a11, a12, a13, a21, a22, a23, a31, a32, a33 = a:components()
- local bx, by, bz, b11, b12, b13, b21, b22, b23, b31, b32, b33 = b:components()
- local x = ax*bx
- local y = ay*by
- local z = az*bz
- local m11 = a11*b11
- local m12 = a12*b12
- local m13 = a13*b13
- local m21 = a21*b21
- local m22 = a22*b22
- local m23 = a23*b23
- local m31 = a31*b31
- local m32 = a32*b32
- local m33 = a33*b33
- return CFrame.new(x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)
- end
- function update()
- local fold = workspace.DrawStuff
- local tab = {}
- for i,v in pairs(fold:GetChildren()) do
- local teb = {}
- table.insert(teb,v.CFrame)
- table.insert(teb,v.Size)
- table.insert(teb,v.Shape)
- table.insert(tab,teb)
- end
- coroutine.resume(coroutine.create(function()
- remote:FireServer(tab)
- wait(.4)
- local g = workspace:FindFirstChild("FolderOfDraw"..player.Name)
- if g ~= nil then
- g:ClearAllChildren()
- end
- end))
- end
- function drawLine(part1,part2)
- local b1 = part1
- local b2 = part2
- local x = (b1.X+b2.X)/2
- local y = (b1.Y+b2.Y)/2
- local z = (b1.Z+b2.Z)/2
- local midpos = Vector3.new(x,y,z)
- local part = Instance.new("Part",folder)
- part.Anchored = true
- part.CanCollide = false
- part.Color = color
- part.Position = midpos
- part.CFrame = CFrame.new(part.Position,b1)
- local mag = (b1 - b2).Magnitude
- part.Size = Vector3.new(0.4*(pensize/6),0.4*(pensize/6),mag)
- part.Material = "Neon"
- return part
- end
- mouse.Button1Down:Connect(function()
- local hit = mouse.Hit.p
- lastpart = hit
- drawing = true
- end)
- mouse.Button1Up:Connect(function()
- lastpart = nil
- drawing = false
- update()
- end)
- --
- player.Chatted:Connect(function(msg)
- if string.sub(msg:lower(),1,4) == ";clr" then
- folder:ClearAllChildren()
- update()
- elseif string.sub(msg:lower(),1,7) == ";color " then
- local tab = string.split(string.sub(msg:lower(),8)," ")
- local r,g,b = tab[1],tab[2],tab[3]
- if r ~= nil and g ~= nil and b ~= nil then
- color = Color3.fromRGB(r,g,b)
- end
- elseif string.sub(msg:lower(),1,9) == ";setsize " then
- local num = tonumber(string.sub(msg,10))
- if num ~= nil then
- pensize = num
- end
- elseif string.sub(msg:lower(),1,10) == ";distance " then
- local num = tonumber(string.sub(msg,11))
- if num ~= nil then
- distance = num
- end
- end
- end)
- coroutine.resume(coroutine.create(function()
- game:GetService("RunService").RenderStepped:Connect(function()
- if drawing and (folder ~= nil and folder.Parent ~= nil) then
- if lastpart == nil then
- lastpart = mouse.Hit.p
- else
- local pos1 = lastpart
- local pos2 = mouse.Hit.p
- local pos3 = Vector3.new(math.abs(pos1.X-pos2.X),math.abs(pos1.Y-pos2.Y),math.abs(pos1.Z-pos2.Z))
- if pos3.X + pos3.Y + pos3.Z >= distance*1.35 then
- if lastline ~= nil then
- lastline:Destroy()
- end
- local lastpar = pos2
- drawLine(lastpart,lastpar)
- lastpart = lastpar
- else
- if lastline ~= nil then
- lastline:Destroy()
- end
- if lastpart2 == nil then
- lastpart2 = pos2
- else
- lastpart2 = pos2
- end
- lastline = drawLine(lastpart,lastpart2)
- end
- end
- elseif drawing and (folder == nil or folder.Parent == nil) then
- folder = Instance.new("Folder",workspace)
- folder.Name = "DrawStuff"
- mouse.TargetFilter = folder
- else
- lastpart2 = nil
- lastline = nil
- end
- end)
- end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement