Moving a model to the player's mouse position, but the model is moving up to disappearance the entire time?

Heya,
So I’ve wanted to make a simple model builder that puts down a model and when the model is selected before putting it down, it follows the cursor for building help.

This would actually be straightforward for me if the model which is set (on move) to the player’s cursor position would not move up into nothing the entire time. I have set the TargetFilter already, so I don’t really see a reason why this should occur?

Any help is appreciated.

Hey, it would be great if you could send your script so that we can help you.

Make sure TargetFilter is being set to the entire model, and not just a part in it.

game:GetService("RunService").RenderStepped:Connect(function()
	if placing == true then
		if preCohort == nil then
			preCohort = makePreCohort()
			preCohort.Parent = game.Workspace
			attach0 = Instance.new("Attachment", preCohort.PrimaryPart)
		else if preMovePart == nil then
				
				preMovePart = game:GetService("ReplicatedStorage").PremovePart:Clone()
				preMovePart.Parent = game.Workspace
				attach1 = Instance.new("Attachment", preMovePart)
				
				local bind = Instance.new("Beam")
				
				bind.Attachment0 = attach0
				bind.Attachment1 = attach1
				
				bind.Width0 = 2
				bind.Width1 = 2
				
				bind.Parent = game.Workspace
				
			else
				mouse.TargetFilter = preCohort
				preMovePart.CFrame = CFrame.new(mouse.Hit.Position.X, mouse.Hit.Position.Y + preMovePart.Size.Y/2,mouse.Hit.Position.Z)
				preCohort:SetPrimaryPartCFrame(CFrame.new(preMovePart.CFrame.X, 0, preMovePart.CFrame.Z))
			end
		end
	else if placing == false then
			if preCohort then
				preCohort:Destroy()
				preCohort = nil
			end
		end
	end
end)

And yes, I’ve set the TargetFilter to the model already.

The issue is that you’re moving two different parts to the mouse’s cursor. The TargetFilter only works for one part, so it’ll ignore that part, but then you move a different part to the position of the first one, which will then be interfering with mouse.Hit.

The solution is to either put both parts/models (preMovePart and preCohort) into 1 single model and set the target filter to that, or you can use raycasting and put both instances into raycastParams.FilterDescendantInstances.

I’ve done that now, but sadly the error still persists, with it going up to around Y position 1065

It will work as long as all the parts you’re trying to move are included in RaycastParams.FilterDescendantsInstances and RaycastParams.FilterType is set to Enum.RaycastFilterType.Exclude.

I mean, the preMovePart works it’s just the model that goes up. Even when I did this:

preCohort:SetPrimaryPartCFrame(CFrame.new(preMovePart.CFrame.X, 0, preMovePart.CFrame.Z))

You are probably experiencing some issues with TargetFilter and whatnot. An easy solution you can apply is to set CanCollide and CanQuery to false for all parts in the model. This will ensure the game ignores the model when using Mouse.hit.