So today I coded a LocalScript which makes certain bricks with certain names movable when you are holding your left mouse button on them:
local plr = game.Players.LocalPlayer
repeat wait() until plr and plr.Character
local mouse = plr:GetMouse()
local mtarget
local down
mouse.Button1Down:connect(function()
if mouse.Target ~= nil and mouse.Target.Locked == false and mouse.Target.Name == "BuildingBrick" or mouse.Target.Name == "BuildingShelf" then
print(mouse.Target.Name)
mtarget = mouse.Target
down = true
mouse.TargetFilter = mtarget or mouse.Target
end
end)
mouse.Move:Connect(function()
if down == true and mtarget ~= nil then
mtarget.Position = Vector3.new(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)
end
end)
mouse.Button1Up:connect(function()
down = false
mouse.TargetFilter = nil
mtarget = nil
end)
All of this works, but I have been trying to set a range so the brick I'm moving doesn't move too far away from me, I tried a lot of things but I can't manage to work it out, help?

2 comments
Thank you
You are most welome!