I raycasted from the player’s viewport to the world and retrieving what BasePart it intersected with using RaycastResult, after reading RaycastResult.Normal, I have no idea and want to know how to build a CFrame with it’s rotation components using a normalized vector.
I’m not sure exactly what you’re trying to use it for, but if you’re trying to use it for something like a bullet hole where the CFrame faces outwards, you could do
local IntersectionPosition = RaycastResult.Position
local Normal = RaycastResult.Normal
local CF = CFrame.lookAt(IntersectionPosition, IntersectionPosition + Normal)
A better and shorter way to do this is using
local cframe = CFrame.new(Raycast.Position, Raycast.Position + Raycast.Normal)
And there’s no need to define a variable if you’re gonna be using the data only once.
I didn’t really like how the code created a scroll bar, so I made the variables.
(Also CFrame.new is deprecated)
I don’t think so:
Sorry, I should have been more specific. CFrame.new(Eye, LookAt) has been replaced with CFrame.lookAt(Eye, LookAt)
CFrame.new ( Vector3 pos, Vector3 lookAt )
This constructor overload has been replaced byCFrame.lookAt
, which accomplishes a similar goal. It remains for the sake of backward compatibility.
It may be replaced, but it isn’t deprecated yet, so it is totally fine to use it.