Advertisement
KrYn0MoRe

wand detector v1

Aug 5th, 2020 (edited)
1,610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.91 KB | None | 0 0
  1. local plr = owner
  2. local char = plr.Character
  3. local hum = char:FindFirstChildOfClass("Humanoid")
  4. local torso = char:FindFirstChild('Torso') or char:FindFirstChild('UpperTorso')
  5.  
  6. debris = game:GetService("Debris")
  7. tween = game:GetService("TweenService")
  8.  
  9. local equipped = false
  10.  
  11. Tool0 = Instance.new("Tool")
  12. Part1 = Instance.new("Part")
  13. Tool0.Name = "Detector"
  14. Tool0.Parent = plr['Backpack']
  15. Tool0.Grip = CFrame.new(0.138040528, 0, 0.138869286, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  16. Tool0.GripPos = Vector3.new(0.138040528, 0, 0.138869286)
  17. Part1.Name = "Handle"
  18. Part1.Parent = Tool0
  19. Part1.CFrame = CFrame.new(-12.3699999, 0.500003994, 10.9099998, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  20. Part1.Position = Vector3.new(-12.3699999, 0.500003994, 10.9099998)
  21. Part1.Color = Color3.new(0.972549, 0.972549, 0.972549)
  22. Part1.Size = Vector3.new(1, 1, 1)
  23. Part1.BottomSurface = Enum.SurfaceType.Smooth
  24. Part1.BrickColor = BrickColor.new("Institutional white")
  25. Part1.Material = Enum.Material.Neon
  26. Part1.TopSurface = Enum.SurfaceType.Smooth
  27. Part1.brickColor = BrickColor.new("Institutional white")
  28.  
  29. function FindPrimaryParts()
  30.     local List = {}
  31.     for i, v in pairs(workspace:GetDescendants()) do
  32.         if v:IsA("Model") then
  33.             if v.PrimaryPart or v:FindFirstChild("HumanoidRootPart") or v:FindFirstChildOfClass("Humanoid") or v:FindFirstChild("Head") then
  34.                 if v ~= char then
  35.                     table.insert(List, v)
  36.                 end
  37.             end
  38.         end
  39.     end
  40.     return List
  41. end
  42.  
  43. function FindTouched()
  44.     local List = {}
  45.     for i, v in pairs(workspace:GetDescendants()) do
  46.         if v:FindFirstChildOfClass("TouchTransmitter") then
  47.             if v ~= char then
  48.                 table.insert(List, v)
  49.             end
  50.         end
  51.     end
  52.     return List
  53. end
  54.  
  55. local handle = Part1
  56. local tool = Tool0
  57.  
  58. local beep = Instance.new("Sound",handle)
  59. beep.SoundId = "rbxassetid://3378132335"
  60. beep.Volume = 0.5
  61.  
  62. local target = nil
  63. local targetbox = nil
  64.  
  65. local hitboxes = {}
  66.  
  67. tool.Equipped:Connect(function()
  68.     equipped = true
  69. end)
  70.  
  71. tool.Unequipped:Connect(function()
  72.     equipped = false
  73.     beep:Stop()
  74.     if targetbox then
  75.         targetbox:Destroy()
  76.     end
  77.     target = nil
  78. end)
  79.  
  80. local remote = Instance.new("RemoteEvent",char)
  81. remote.Name = "wandremote"
  82.  
  83. local code = [[
  84. local mouse = game:GetService("Players").LocalPlayer:GetMouse()
  85. local remote = script.Parent
  86. mouse.Button1Down:Connect(function()
  87.     remote:FireServer(1,mouse.Target)
  88. end)
  89. mouse.KeyDown:Connect(function(key)
  90.     if key == "x" then
  91.         remote:FireServer(2,"destroy")
  92.     end
  93. end)
  94. ]]
  95.  
  96. NLS(code,remote)
  97.  
  98. remote.OnServerEvent:Connect(function(plr,mode,data,data2)
  99.     if mode == 1 and equipped then
  100.         if data and data.Parent and data.Name ~= ("Base" and "Baseplate") --[[and (data.Parent:FindFirstChild("KrY's Detector " .. name + name2) or data:FindFirstChild("KrY's Detector " .. name + name2))]] then
  101.             if targetbox then
  102.                 targetbox:Destroy()
  103.             end
  104.             target = data
  105.             targetbox = Instance.new("SelectionBox",target)
  106.             targetbox.SurfaceTransparency = 1
  107.             targetbox.LineThickness = .1
  108.             targetbox.Adornee = target
  109.             targetbox.Color3 = Color3.new(58/255, 125/255, 21/255)
  110.         end
  111.     end
  112.     if mode == 2 and equipped then
  113.         if data == "destroy" and target and target.Parent then
  114.             target:Destroy()
  115.             target = nil
  116.             targetbox = nil
  117.         end
  118.     end
  119. end)
  120.  
  121. spawn(function()
  122.     while tool do
  123.         wait()
  124.         if equipped then else continue end
  125.         beep:Play()
  126.         handle.BrickColor = BrickColor.Random()
  127.         local touch = FindTouched()
  128.         local primaryparts = FindPrimaryParts()
  129.         for _,t in ipairs(touch) do
  130.             local hb = t:FindFirstChild("Selection boi " .. plr.Name)
  131.             if not t:FindFirstChild("KrY's Detector " .. plr.Name) then
  132.                 local confirm = Instance.new("IntValue",t)
  133.                 confirm.Name = ("KrY's Detector " .. plr.Name)
  134.                 hb = Instance.new("SelectionBox",t)
  135.                 hb.Name = ("Selection boi " .. plr.Name)
  136.                 hb.SurfaceTransparency = 1
  137.                 hb.LineThickness = .1
  138.                 hb.Adornee = t
  139.                 hb.Color3 = Color3.new(175/255, 221/255, 255/255)
  140.                 hitboxes[hb] = hb
  141.             end
  142.             if not hitboxes[t] then
  143.                 hitboxes[t] = hb
  144.             end
  145.         end
  146.         for _,p in ipairs(primaryparts) do
  147.             local hb = p:FindFirstChild("Selection boi " .. plr.Name)
  148.             if not p:FindFirstChild("KrY's Detector " .. plr.Name) then
  149.                 local confirm = Instance.new("IntValue",p)
  150.                 confirm.Name = ("KrY's Detector " .. plr.Name)
  151.                 hb = Instance.new("SelectionBox",p)
  152.                 hb.Name = ("Selection boi " .. plr.Name)
  153.                 hb.SurfaceTransparency = 1
  154.                 hb.LineThickness = .1
  155.                 hb.Adornee = p
  156.                 hb.Color3 = Color3.new(175/255, 221/255, 255/255)
  157.                 hitboxes[hb] = hb
  158.             end
  159.             if not hitboxes[p] then
  160.                 hitboxes[p] = hb
  161.             end
  162.         end
  163.         for i,v in pairs(hitboxes) do
  164.             if v then else continue end
  165.             local vis = true
  166.             v.Visible = vis
  167.             if target then
  168.                 targetbox.Visible = vis
  169.             end
  170.         end
  171.         wait(0.25)
  172.         for i,v in pairs(hitboxes) do
  173.             if v then else continue end
  174.             local vis = false
  175.             v.Visible = vis
  176.             if target then
  177.                 targetbox.Visible = vis
  178.             end
  179.         end
  180.         wait(0.25)
  181.     end
  182. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement