I was wondering how I could go about making a player face a certain part without changing the y-axis or making the player fall over.
--[[
--game.Workspace.Player1
--game.Workspace.Part1
--]]
game.Workspace.Player1:SetPrimaryPartCFrame() -- ? Make player face 'Part1' without changing y axis of player
local part = --the part you want
local char = --player character model
local charCF = char:GetPrimaryPartCFrame()
local direction = ((part.Position - charCF.Position) * Vector3.new(1,0,1)) + Vector3.new(0, charCF.Position.Y,0)
local newCF = CFrame.lookAt(charCF.Position, charCF.Position + direction, Vector3.new(0,1,0))
All you needed to do was set the look direction to the same height as the player’s character. Did that by first getting the direction, then turning only the Y value to 0 by multiplying the first vector then set the Y value to the player’s height by adding the second vector. If you have any more questions ill try to answer.
--------EDIT--------
forgot the part where you assign the newCF variable.
char:SetPrimaryPartCFrame(newCF)
also not sure if this will make the player fall or not but give it a shot.
The ‘lookAt’ constructor doesn’t expect three arguments, it only expects two, the first being the origin and the second being the direction at which to look at.