Advertisement
DrawingJhon

ToggleCollision Tool

Nov 1st, 2022
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local player = game:GetService("Players").LocalPlayer
  2. local mouse = player:GetMouse()
  3.  
  4. local tool = Instance.new("Tool")
  5. tool.Name = "ToggleTouch"
  6. tool.RequiresHandle = false
  7. tool.CanBeDropped = false
  8. tool.Parent = player.Backpack
  9.  
  10. local backup = _G.TiBackup or {}
  11. local conns = _G.TiConns or {}
  12. _G.TiBackup = backup
  13. _G.TiConns = conns
  14.  
  15. tool.Activated:Connect(function()
  16.     local part = mouse.Target
  17.     if not part then return end
  18.    
  19.     local saved = backup[part]
  20.     if saved then
  21.         part.Color = saved.Color
  22.         saved.Clone:Destroy()
  23.         conns[part] = part.Touched:Connect(function() end)
  24.         backup[part] = nil
  25.     else    
  26.         local ti = part:FindFirstChildOfClass("TouchTransmitter")
  27.         if not ti then return end
  28.         local conn = conns[part]
  29.         if conn then
  30.             conn:Disconnect()
  31.         end
  32.         ti:Destroy()
  33.         local clone = part:Clone()
  34.         clone.Name = part.Name.."'s clone"
  35.         clone.Transparency = 1
  36.         clone.Parent = workspace
  37.         backup[part] = {
  38.             Color = part.Color,
  39.             Clone = clone
  40.         }
  41.         part.Color = Color3.new(1, 0, 0)
  42.     end
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement