2D Plane Lock / Disable Z-Axis

I’m trying a 2.5D game, and I’m trying to figure out how to prevent parts from moving on the Z-axis, which is where I want to start before doing it to characters. I’ve tried a few things already: Scripting it, using PlaneConstraints, and using AlignPositions. I’ve thought PlaneConstraints would work, but it didn’t seem to. All I did was add one constraint that’s attached to an unanchored part and an invisible anchored part, which resulted in a glitchy block that still moves on the Z-axis.

This is the script I tried for locking the Z-axis.

local part = script.Parent

local function lockZ()
	local currentPosition = part.Position
	part.Position = Vector3.new(currentPosition.X, currentPosition.Y, 0)


This only resulted in the part teleporting weirdly.