Look at Brick script makes me face only one way

So I am using this script:

function lookAt(chr,target)
	if chr.PrimaryPart then
		local chrPos=chr.PrimaryPart.Position
		local tPos=target.Position
		local modTPos=Vector3.new(tPos.X,chrPos.Y,tPos.X)
		local newCF=CFrame.new(chrPos,modTPos)
		chr:SetPrimaryPartCFrame(newCF)
	end
end

Prompt.Triggered:Connect(function(Player)
	local Char = Player.Character
	lookAt(Char, script.Parent.Parent)
end)

but every time I run the code it makes me face one way:

You used .X twice, change the third one to Z

Also use CFrame.lookAt(), when constructing a cframe to look at a point

2 Likes