Im trying to make an NPC look away from the target. So far I tried using
local TCF = target:GetPrimaryPartCFrame()
local NCF = NPC:GetPrimaryPartCFrame()
local newCF = TCF:ToObjectSpace(NCF)
NPC:SetPrimaryPartCFrame(CFrame.new(NCF.Position, -TCF.Position))
Doesnt work! I tried adding
local TCF = target:GetPrimaryPartCFrame()
local NCF = NPC:GetPrimaryPartCFrame()
local newCF = CFrame.new(NCF.Position, TCF.Position)
newCF = newCF * CFrame.Angles(math.rad(180), math.rad(180), math.rad(180))
One way this can be approached is by using the CFrame Constructor CFrame.new(Vector3 pos, Vector3 lookkAt). You can supply lookAt with the NPC’s Position - the Vector distance between the player and the NPC. Using the variables supplied, you could try NPC:SetPrimaryPartCFrame(CFrame.new(NCF.Position,NCF.Position-(TCF.Position-NCF.Position))) to achieve the desired effect.