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

01-- Example
02 
03local Model = Instance.new("Model", workspace)
04 
05local Part = Instance.new("Part")
06Part.Anchored = true
07Part.Parent = game.Workspace.Model
08 
09Model.PrimaryPart = Part
10 
11local Player = game.Players.LocalPlayer
12local Mouse = Player:GetMouse()
13 
14local function MovePart()
15    Mouse.TargetFilter = Part -- Ignores the part
16 
17    Model:MoveTo(Vector3.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)) -- Not using CFrames
18end
19 
20Mouse.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