Hi i have a script when the player clicks a brick is going to spawn where the click was and i also figured out how the only problem is that i can not spown it left and right and most of the time it glitches i know it is a SIMPLE problem and since 2 days i am trying to solve it without success this is the Spowning script:

local cubeSize = 2.2
function convert(axis)
	return math.floor(axis / cubeSize) * cubeSize
end
			
local x,y,z = convert(mouseposx),convert(mouseposy),convert(mouseposz)

scriptfordestroy.Parent=clickdetector
part.CFrame=CFrame.new(x,y+1,z)
part.Rotation = Vector3.new(0,0,0)
part.Size=Vector3.new(2.2,2.2,2.2)
part.BrickColor=BrickColor.new(brickcolor)

If you Know Any Resourses that could help me please tell me Thank You ????