In theory, you do not need to put click detectors and the same script in EVERY part or model. You can simply use the HopperBin that ROBLOX has to simulate both not holding a tool, and reaching these goals of moving the object. In fact, people have already done this and created free models, such as the great Malvaviscos. His answer was simple.
Note I do not take credit for this in any way, this scripting is done by Malvaviscos and used in his Force Grip model.
04 | local position = Instance.new( "BodyPosition" ) |
06 | position.maxForce = Vector 3. new( 100000 , 100000 , 100000 ) |
10 | function onButton 1 Down(mouse) |
11 | if mouse.Target ~ = nil then |
12 | if (mouse.Target.Position - game.Players.LocalPlayer.Character.Head.Position).magnitude < = maxSelectRadius and not mouse.Target.Anchored then |
14 | position.Parent = object |
15 | position.position = game.Players.LocalPlayer.Character.Head.Position + (mouse.Hit.p - game.Players.LocalPlayer.Character.Head.Position).unit * holdRadius |
21 | function onButton 1 Up(mouse) |
29 | position.position = game.Players.LocalPlayer.Character.Head.Position + (mouse.Hit.p - game.Players.LocalPlayer.Character.Head.Position).unit * holdRadius |
33 | function onSelected(mouse) |
34 | mouse.Button 1 Down:connect( function () onButton 1 Down(mouse) end ) |
35 | mouse.Button 1 Up:connect( function () onButton 1 Up(mouse) end ) |
36 | mouse.Move:connect( function () onMove(mouse) end ) |
39 | script.Parent.Selected:connect(onSelected) |
40 | script.Parent.Deselected:connect(onButton 1 Up) |