Advertisement
Ubicast

Draw Tool Script | ROBLOX

Nov 21st, 2020
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. local plyr = game.Players.LocalPlayer
  2. local c = plyr.Character
  3. local RunService = game:service'RunService'
  4. local mouse = game.Players.LocalPlayer:GetMouse()
  5. local draw2 = false
  6. local colorA = 1
  7. local lastPos
  8.  
  9. local tool = Instance.new("HopperBin", plyr.Backpack)
  10. tool.Name = "Draw"
  11.  
  12. function draw(obj)
  13.     local lastPos = obj.CFrame.p
  14.     coroutine.wrap(function()
  15.         while wait() do
  16.             if draw2 then
  17.                 while draw2 do
  18.                     RunService.Stepped:wait()
  19.                     objC = obj:Clone()
  20.                     objC.Parent = c
  21.                     objC.Anchored = true
  22.                     local distance = (lastPos- obj.CFrame.p).magnitude
  23.                     objC.Size = Vector3.new(.2,.2,distance)
  24.                     objC.CFrame = CFrame.new(lastPos,obj.Position)*CFrame.new(0,0,-distance/2)
  25.                     lastPos = obj.CFrame.p
  26.                 end
  27.             else
  28.                 break
  29.             end
  30.         end
  31.     end)
  32. end
  33.  
  34. tool.Selected:Connect(function(mouse)
  35.     mouse.Button1Down:Connect(function(mouse)
  36.         part = Instance.new("Part", c)
  37.         part.Name = "location"
  38.         part.BottomSurface = 0
  39.         part.TopSurface = 0
  40.         part.BrickColor = BrickColor.Black()
  41.         part.FormFactor = "Custom"
  42.         part.Size = Vector3.new(0.2, 0.2, 0.2)
  43.         part.Anchored = true
  44.         part.Locked = true
  45.         coroutine.wrap(function()
  46.             while part ~= nil do
  47.                 part.CFrame = CFrame.new(plyr:GetMouse().Hit.p.x,plyr:GetMouse().Hit.p.y,plyr:GetMouse().Hit.p.z)
  48.                 RunService.Stepped:wait()
  49.             end
  50.         end)()        
  51.         draw(part)
  52.         draw2 = true
  53.     end)
  54.    
  55.     mouse.Button1Up:Connect(function(mouse)
  56.         game:service'Debris':AddItem(part, 0)
  57.         draw2 = false
  58.         pcall(function()
  59.             lastPos = nil
  60.         end)
  61.     end)
  62. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement