Advertisement
BobMe

DrawL

Aug 22nd, 2020 (edited)
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. wait(4)
  2. local player = game.Players.LocalPlayer
  3. local mouse = player:GetMouse()
  4. local us = game:GetService("UserInputService")
  5. local lastline = nil
  6. local lastpart = nil
  7. local lastpart2 = nil
  8. local folder = workspace:FindFirstChild("DRAWDING")
  9. if folder == nil then
  10. folder = Instance.new("Folder",workspace)
  11. folder.Name = "DRAWDING"
  12. end
  13. local drawing = false
  14. local remote = player:WaitForChild("lud")
  15. local pensize = 3
  16. local distance = 1.5
  17. local color = Color3.fromRGB(145,145,145)
  18. --
  19. folder.Name = "DrawStuff"
  20. mouse.TargetFilter = folder
  21.  
  22. function subtractcf(a, b)
  23. local x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33 = a:components()
  24. return CFrame.new(x - b.x, y - b.y, z - b.z, m11, m12, m13, m21, m22, m23, m31, m32, m33);
  25. end
  26.  
  27. local function multiplyCFrame(a, b)
  28. local ax, ay, az, a11, a12, a13, a21, a22, a23, a31, a32, a33 = a:components()
  29. local bx, by, bz, b11, b12, b13, b21, b22, b23, b31, b32, b33 = b:components()
  30. local x = ax*bx
  31. local y = ay*by
  32. local z = az*bz
  33. local m11 = a11*b11
  34. local m12 = a12*b12
  35. local m13 = a13*b13
  36. local m21 = a21*b21
  37. local m22 = a22*b22
  38. local m23 = a23*b23
  39. local m31 = a31*b31
  40. local m32 = a32*b32
  41. local m33 = a33*b33
  42. return CFrame.new(x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)
  43. end
  44.  
  45. function update()
  46. local fold = workspace.DrawStuff
  47. local tab = {}
  48. for i,v in pairs(fold:GetChildren()) do
  49. local teb = {}
  50. table.insert(teb,v.CFrame)
  51. table.insert(teb,v.Size)
  52. table.insert(teb,v.Shape)
  53. table.insert(tab,teb)
  54. end
  55. coroutine.resume(coroutine.create(function()
  56. remote:FireServer(tab)
  57. wait(.4)
  58. local g = workspace:FindFirstChild("FolderOfDraw"..player.Name)
  59. if g ~= nil then
  60. g:ClearAllChildren()
  61. end
  62. end))
  63. end
  64.  
  65. function drawLine(part1,part2)
  66. local b1 = part1
  67. local b2 = part2
  68. local x = (b1.X+b2.X)/2
  69. local y = (b1.Y+b2.Y)/2
  70. local z = (b1.Z+b2.Z)/2
  71. local midpos = Vector3.new(x,y,z)
  72. local part = Instance.new("Part",folder)
  73. part.Anchored = true
  74. part.CanCollide = false
  75. part.Color = color
  76. part.Position = midpos
  77. part.CFrame = CFrame.new(part.Position,b1)
  78. local mag = (b1 - b2).Magnitude
  79. part.Size = Vector3.new(0.4*(pensize/6),0.4*(pensize/6),mag)
  80. part.Material = "Neon"
  81. return part
  82. end
  83.  
  84. mouse.Button1Down:Connect(function()
  85. local hit = mouse.Hit.p
  86. lastpart = hit
  87. drawing = true
  88. end)
  89.  
  90. mouse.Button1Up:Connect(function()
  91. lastpart = nil
  92. drawing = false
  93. update()
  94. end)
  95.  
  96. --
  97.  
  98. player.Chatted:Connect(function(msg)
  99. if string.sub(msg:lower(),1,4) == ";clr" then
  100. folder:ClearAllChildren()
  101. update()
  102. elseif string.sub(msg:lower(),1,7) == ";color " then
  103. local tab = string.split(string.sub(msg:lower(),8)," ")
  104. local r,g,b = tab[1],tab[2],tab[3]
  105. if r ~= nil and g ~= nil and b ~= nil then
  106. color = Color3.fromRGB(r,g,b)
  107. end
  108. elseif string.sub(msg:lower(),1,9) == ";setsize " then
  109. local num = tonumber(string.sub(msg,10))
  110. if num ~= nil then
  111. pensize = num
  112. end
  113. elseif string.sub(msg:lower(),1,10) == ";distance " then
  114. local num = tonumber(string.sub(msg,11))
  115. if num ~= nil then
  116. distance = num
  117. end
  118. end
  119. end)
  120.  
  121. coroutine.resume(coroutine.create(function()
  122. game:GetService("RunService").RenderStepped:Connect(function()
  123. if drawing and (folder ~= nil and folder.Parent ~= nil) then
  124. if lastpart == nil then
  125. lastpart = mouse.Hit.p
  126. else
  127. local pos1 = lastpart
  128. local pos2 = mouse.Hit.p
  129. local pos3 = Vector3.new(math.abs(pos1.X-pos2.X),math.abs(pos1.Y-pos2.Y),math.abs(pos1.Z-pos2.Z))
  130. if pos3.X + pos3.Y + pos3.Z >= distance*1.35 then
  131. if lastline ~= nil then
  132. lastline:Destroy()
  133. end
  134. local lastpar = pos2
  135. drawLine(lastpart,lastpar)
  136. lastpart = lastpar
  137. else
  138. if lastline ~= nil then
  139. lastline:Destroy()
  140. end
  141. if lastpart2 == nil then
  142. lastpart2 = pos2
  143. else
  144. lastpart2 = pos2
  145. end
  146. lastline = drawLine(lastpart,lastpart2)
  147. end
  148. end
  149. elseif drawing and (folder == nil or folder.Parent == nil) then
  150. folder = Instance.new("Folder",workspace)
  151. folder.Name = "DrawStuff"
  152. mouse.TargetFilter = folder
  153. else
  154. lastpart2 = nil
  155. lastline = nil
  156. end
  157. end)
  158. end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement