Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Make a part follow the mouse and *not* clip through other parts?

Making a build system, and I would like it to function similarly to 'classic' build tools, where the object would not clip through any other part. How would I do this?

2 comments

0

newPart.Position = mouse.Hit.Position, we want to use Position instead of CFrame because Position will automatically re-position its self if extends of a part intersect with any other instance

0

Position just moves the part up until it is clear. I need it to function like classic build systems

1 answer

Ok I tried my code and it did not work. The solution is to create a model containing just the part (the part has to be the primary part). Use a function called MoveTo() which takes a vector3 value inside of it. Example

-- Example

local Model = Instance.new("Model", workspace)

local Part = Instance.new("Part")
Part.Anchored = true
Part.Parent = game.Workspace.Model

Model.PrimaryPart = Part

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local function MovePart()
	Mouse.TargetFilter = Part -- Ignores the part

	Model:MoveTo(Vector3.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)) -- Not using CFrames
end

Mouse.Move:Connect(MovePart)

Hope this works!

2 comments

0

Uhhh, did you even read his title? "Make a part follow the mouse /and/ not clip through other parts"

0

Fixed!

This discussion is preserved as it was. New answers, comments, and votes are closed.