Mouse.Hit messing up with item preview


So basically, I am trying to make a placement system. It works decently, however the item’s preview seems to be messing with where it’s going to be placed. How can I ignore this item?

Example, when moving the cursor away from me, the item preview only moves when the cursor goes off of the wall itself.

Here’s a snippet of my code which basically determines what goes where:

	if not model.PrimaryPart then
		model.PrimaryPart = model:FindFirstChild('BoundingBox')
	local function SnapTo(num, inc)
		return math.round(num / inc) * inc
	for i,v in pairs(model:GetDescendants()) do
		if v:IsA('BasePart') then
			v.CanCollide = false
			if v.Name ~= 'BoundingBox' then
				v.Transparency = 0.5
				v.Transparency = 1
	local gridPart = workspace.Plot
	local placementPosWorld = mouse.Hit.Position
	local gridNodeSize = module.GridSize
	local s,e  = pcall(function()
		model.Parent = gridPart
	if not s then return end
	local yPos = gridPart.Size + (gridPart.CFrame.UpVector * (gridPart.Size.Y / 2))
	model:SetPrimaryPartCFrame(, module.GridSize), 0, SnapTo(mouse.Hit.Position.Z, module.GridSize)))
	if rotation ~= 0 then 
		model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0, math.pi / 2 * rotation, 0))
	return model

Can we see the source code? That may help.

1 Like

All you have to do is add an if statement to ignore the preview:

local MousePos -- this is where the mouse should be detecting
if Mouse.Target == preview then
    preview.Position =,0,0)
    MousePos = Mouse.Hit.Position
    preview.Position = Mouse.Hit.Position
1 Like

I am not sure if I explained it properly. Basically, mouse.Hit is landing on the item preview when it should be landing on the plot.

Added a snippet which places everything in the original post.

Try setting the Mouse.TargetFilter to the instance you’re trying to ignore

1 Like