So i was using primarypart to move the models but its quite sloppy and shaky so i decided to use moveto instead but whenever i try and drag on random area it's lagging like so bad and the script will suddenly not work.
------This is previous script ---------
mouse.Move:connect(function() pcall(function() if _G.target and _G.down then -- Don't mind the global variable here, i used modulescript now. local posX,posZ = mouse.Hit.X,mouse.Hit.Z _G.target:SetPrimaryPartCFrame(CFrame.new(posX,_G.target.PrimaryPart.Position.Y,posZ)) end end) end)
---------------new script----------------------
mouse.Move:connect(function() pcall(function() if target and down then target:MoveTo(Vector3.new(mouse.Hit.p.X, mouse.Hit.p.Y + (target:GetExtentsSize().Y / 2), mouse.Hit.p.Z)) end end) end)
-----check if mouse target is a model and finds the player who owns the model
mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Parent:IsA('Model') then if mouse.Target.Parent:FindFirstChild(plyName) then for _,v in pairs(mouse.Target.Parent:GetChildren()) do if v:IsA("BasePart") then v.CanCollide = false down = true target = mouse.Target.Parent mouse.TargetFilter = mouse.Target end end end end end)