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

Why is my move tool separating the bricks in a model?

Asked by
Seyfert 90
6 years ago
Edited 6 years ago

I have a move tool I created where I can move drag around bricks that are in a model. It works okay if I click and hold and drag the objects around. However, if I just click once on a part of the brick that is in a model, that brick gets moved and the other one does not...any ideas?

Here is my code

 local player = game.Players.LocalPlayer
 local mouse = player:GetMouse()
 local moveEvent = nil --We need to store the event so we may disconnect when left-click is released

mouse.Button1Down:connect(function()
    local target = mouse.Target
    if target and target.Parent.Name == "Furniture" then
            target.Parent.PrimaryPart = target
            mouse.TargetFilter = target
                moveEvent = mouse.Move:connect(function()
                    if (player.Character.UpperTorso.Position - mouse.TargetFilter.Position).magnitude <= 35 then
                        target.Parent:SetPrimaryPartCFrame(CFrame.new((mouse.Hit.p)))    
                    else  
                        moveEvent:disconnect()
                    end                   
              end)
       end
 end)

1 answer

Log in to vote
0
Answered by
Eqicness 255 Moderation Voter
6 years ago

Hm, your script looks fine.

What you can try doing is not setting the model's PrimaryPart to the mouse's target before hand, and just use a preset primary part, although this shouldn't make a difference. If you don't want your model to be anchored, try welding all the parts together with a weld script such as Quenty's qPerfectionWeld, or else make sure they're all anchored.

0
How would I use a preset primary part? How would I put that in my script? Do I put a stringvalue inside the model with the name of the primarypart? The script would still have to wait for me to click on the brick?? Seyfert 90 — 6y
0
All you have to do is click the model, click the field where it says "Primary Part", and set the primary part to a part inside the model - Preferably the one closest to the center or biggest. Eqicness 255 — 6y
0
I tried that and it has not really changed anything. Any other possible ideas? Seyfert 90 — 6y
0
No idea... that's super strange. Eqicness 255 — 6y
Ad

Answer this question