DevKxnq1221

Untitled

Oct 24th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. debounce = false
  2. local vPlayer = game.Players.LocalPlayer
  3. local SBox = Instance.new("SelectionBox")
  4. local Tool = script.Parent;
  5.  
  6. local Select
  7. local Orig 
  8. local Dragger
  9.  
  10. function onButton1Down(mouse)
  11.  
  12.     local Target = mouse.Target
  13.     local Sound = Instance.new("Sound")-- The "ding" sound
  14.     Sound.SoundId = "rbxasset://sounds\\electronicpingshort.wav"
  15.     Sound.Name = "PewPew"
  16.     Sound.Parent = Tool
  17.  
  18.     if Target and Target:IsA("BasePart") and not Target.Locked then
  19.         if debounce == false then
  20.         debounce = true
  21.         Orig = Target
  22.         Select = Orig:clone()
  23.  
  24.         Select.Parent = game.Workspace
  25.         Select.Position = Orig.Position + Vector3.new(0, 0.4, 0)
  26.  
  27.         Dragger = Instance.new("Dragger")
  28.         pcall(function() Dragger:MouseDown(Select, Vector3.new(0, 0, 0), {Select}) end)
  29.  
  30.         SBox.Adornee = Select
  31.         Sound:Play()
  32.         wait(0)-- Edit this to how long you would like to wait until the next copy
  33.         mouse.Icon = "rbxasset://textures\\DragCursor.png"
  34.         debounce = false
  35.         end
  36.     end
  37. end
  38.  
  39. function onButton1Up(mouse)
  40.     if Dragger then
  41.         Orig = nil
  42.         pcall(function() Dragger:MouseUp() end)
  43.         Select = nil
  44.         SBox.Adornee = nil
  45.         Dragger = nil
  46.         mouse.Icon = "rbxasset://textures\\CloneOverCursor.png"
  47.     end
  48. end
  49.  
  50. function onMouseMove(mouse)
  51.     if Dragger then
  52.         mouse.Icon = "rbxasset://textures\\GrabRotateCursor.png"
  53.         pcall(function() Dragger:MouseMove(mouse.UnitRay) end)
  54.     else
  55.         local Target = mouse.Target
  56.         if Target and Target:IsA("BasePart") and not Target.Locked then
  57.             mouse.Icon = "rbxasset://textures\\CloneOverCursor.png"
  58.         else
  59.             mouse.Icon = "rbxasset://textures\\CloneCursor.png"
  60.         end
  61.     end
  62. end
  63.  
  64. function onKeyDown(key)
  65.     if Dragger then
  66.         key = key:lower()
  67.         if key == 'r' then
  68.             Dragger:AxisRotate(Enum.Axis.Y)
  69.         elseif key == 't' then
  70.             Dragger:AxisRotate(Enum.Axis.Z)
  71.         end
  72.     end
  73. end
  74.  
  75. function onEquippedLocal(mouse)
  76.     SBox.Color = BrickColor.new("Cyan")
  77.     SBox.Parent = vPlayer.PlayerGui
  78.  
  79.     mouse.Button1Down:Connect(function() onButton1Down(mouse) end)
  80.     mouse.Button1Up:Connect(function() onButton1Up(mouse) end)
  81.     mouse.Move:Connect(function() onMouseMove(mouse) end)
  82.     mouse.KeyDown:Connect(onKeyDown)
  83. end
  84.  
  85. function onUnequippedLocal(mouse)
  86.     if Tool:findFirstChild("PewPew") then
  87.         Tool.PewPew:remove()
  88.     end
  89.     if Dragger then
  90.         Orig = nil
  91.         pcall(function() Dragger:MouseUp() end)
  92.         Select = nil
  93.         SBox.Adornee = nil
  94.         Dragger = nil
  95.     end
  96. end
  97.  
  98. Tool.Equipped:Connect(onEquippedLocal)
  99. Tool.Unequipped:Connect(onUnequippedLocal)
Advertisement
Add Comment
Please, Sign In to add comment