I'm trying to make a part anchor when it hits another part ( not itself, part's name must be "Part") but it's not really working, actually it anchors ahead of me sometimes even tho it shouldn't anchor when it meets a hat.Any help please?
bin = script.Parent function press(mouse) if sel == true then hit = mouse.Target local point = mouse.Hit.p s = Instance.new("Part") s.CanCollide = false s.FormFactor = "Custom" s.Size=Vector3.new(14.6, 0.8, 13.4) s.Anchored = false s.BrickColor = BrickColor.new("Really red") s.Name = "Air" s.TopSurface = "Smooth" s.BottomSurface = "Smooth" s.Parent = workspace s.CFrame = script.Parent.Parent.Parent.Character.Torso.CFrame*CFrame.new(0, 3, -15) m = Instance.new("SpecialMesh", s) m.MeshType = "Sphere" r = Instance.new("ObjectValue") r.Value = script.Parent.Parent.Parent r.Parent = s r.Name = "creator" c = script.CleanUp:clone() c.Disabled = false c.Parent = s s.Touched:connect(function(Part) if Part.Name == "Part" then s.Anchored = true end end) wait(0.2) press(mouse) end end function onButton1Down(mouse) sel = true if sel == true then hit = mouse.Target local point = mouse.Hit.p s = Instance.new("Part") s.FormFactor = "Custom" s.CanCollide = false s.Size=Vector3.new(14.6, 0.8, 13.4) s.Anchored = false s.BrickColor = BrickColor.new("Really red") s.Name = "Air" s.TopSurface = "Smooth" s.BottomSurface = "Smooth" s.Parent = game.Workspace s.CFrame = script.Parent.Parent.Parent.Character.Torso.CFrame*CFrame.new(0, 3, -15) m = Instance.new("SpecialMesh", s) m.MeshType = "Sphere" c = script.CleanUp:clone() c.Disabled = false c.Parent = s r = Instance.new("ObjectValue") r.Value = script.Parent.Parent.Parent r.Parent = s r.Name = "creator" s.Touched:connect(function(Part) if Part.Name == "Part" then s.Anchored = true end end) press(mouse) end end function onButton1Up(mouse) sel = false end mouse = script.Parent.Parent.Parent:GetMouse() mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end)