Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Abandion 118
6 years ago

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?

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 EpicMetatableMoment 1444 — 6y
0
Position just moves the part up until it is clear. I need it to function like classic build systems Abandion 118 — 6y

1 answer

Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago
Edited 6 years ago

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!

0
Uhhh, did you even read his title? "Make a part follow the mouse /and/ *not* clip through other parts" AIphanium 124 — 6y
0
Fixed! zblox164 531 — 6y
Ad

Answer this question