Part flashing repeatedly when character is close...?

so i have a block placement system, but when the preview happens, it keeps flashing for some reason.
this is the part where it gets a part with a selection box, the part is invisible.

local part = game.Workspace:FindFirstChild("Select")  or game.ReplicatedStorage.Select:Clone()

and this is the placement of the preview

mouse.Move:Connect(function()
	if equipped == true then
		print("moved")
		local target = mouse.Target
		if target then
			local surface = mouse.TargetSurface
			local pos = Surface(surface)
			mouse.TargetFilter = part
			local x = mouse.Hit.X
			local y = mouse.Hit.Y
			local z = mouse.Hit.Z
			part.Position = pos + target.Position
		end
		--Vector3.new(math.floor(x/4) * 4, math.floor(y/4) * 4 + 2, math.floor(z/4) * 4)
	end 

end)

(pos is just adding numbers based on the face the mouse is on)

it flashes sometimes but dosn’t other, seems to work when character is far away but flashes when near, it has flashed when being far away too, looks very random.

video: Easyupload.io - Upload files for free and transfer big files easily.

(edit: nevermind, i don’t think it matters when the character is close or not, but it seems to be flashing most of the time)

If you mean you have 2 identical sized Parts at the same location (one Part, one preview Part) then you’ll get what’s called z fighting. The computer can’t tell which of the 2 surfaces that face the camera is closer, so it tries to render both at the same time.
Try making the preview Part .01 studs larger in all 3 dimensions and semi-transparent so both can be seen, but the surfaces won’t be at the exact same spot.

i don’t think it’s z fighting, heres the game,

What is the script for the placement and deletion of the preview Part?
The game shows me a split second view of the preview when I drag the mouse across the wood Part, but it doesn’t stay in view at all.
Is the script sensing the preview box as a non-target and removing the preview instantly?

I know there have been other posts about block placement grid problems in other posts. You may find some answers if you search the forum.

i can dm you the game file if you want, what is your discord?

the part is never deleded, just made invisible and placed at a very far away place.

But the issue is that the preview Part isn’t staying where the mouse is, it is being hidden.

Most block placement building games leave the preview block visible when you keep the mouse in one position.