SelectionBox and ClickDetectors not being removed?
I came across another problem working with the code, no errors show though. I don't see any problem either.
Here's the code:
01 | local tool = script.Parent |
07 | tool.Equipped:connect( function () |
09 | myhum = mychar:WaitForChild( "Humanoid" ) |
11 | hold = myhum:LoadAnimation(tool:WaitForChild( "Hold" )) |
15 | for _,part in pairs (workspace:GetChildren()) do |
16 | if part:IsA( "Part" ) then |
17 | if (part.Position - mychar.Torso.Position).Magnitude < = 12 then |
18 | local box = Instance.new( "SelectionBox" , part) |
20 | box.Color 3 = Color 3. new( 255 , 170 , 0 ) |
21 | local click = Instance.new( "ClickDetector" , part) |
22 | click.MouseClick:connect( function () |
23 | tool.Handle.Anchored = true |
24 | tool.Handle.Rotation = Vector 3. new( 0 , 0 , 0 ) |
25 | tool.Handle.Parent = workspace |
26 | workspace.Handle.Name = mychar.Name.. "_" ..tool.Name |
27 | workspace:FindFirstChild(mychar.Name.. "_" ..tool.Name).Position = part.Position + Vector 3. new( 0 , part.Size.Y, 0 ) |
37 | tool.Unequipped:connect( function () |