Advertisement
Guest User

Building System 1.1 -- Delete Tool

a guest
Aug 28th, 2020
2,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. -- Variables
  2.  
  3. local player = game.Players.LocalPlayer
  4. local mouse = player:GetMouse()
  5. local UIS = game:GetService('UserInputService')
  6. local RS = game:GetService('ReplicatedStorage')
  7. local tool = script.Parent
  8. local Event = RS:WaitForChild('DeleteBlock')
  9. local equipped = false
  10. local Box = Instance.new('SelectionBox')
  11. Box.Color3 = Color3.new(1,0,0)
  12. Box.Parent = workspace
  13.  
  14. tool.Equipped:Connect(function()
  15. equipped = true
  16. end)
  17.  
  18. tool.Unequipped:Connect(function()
  19. equipped = false
  20. Box.Adornee = nil
  21. end)
  22.  
  23.  
  24. -- Selection Box
  25.  
  26. mouse.Move:Connect(function()
  27. local target = mouse.Target
  28. if target then
  29. if target.Parent.Name == player.Name and equipped then
  30. Box.Adornee = target
  31. else
  32. Box.Adornee = nil
  33. end
  34. end
  35. end)
  36.  
  37. -- Delete Block
  38.  
  39. script.Parent.Activated:Connect(function()
  40. local target = mouse.Target
  41. if target then
  42. if target.Parent.Name == player.Name then
  43. Event:FireServer(target)
  44. end
  45. end
  46. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement