I have this code:
local Camera = game.Workspace.CurrentCamera local part = script.Part game:GetService('RunService').RenderStepped:connect(function() part.Parent = Camera part.CFrame = Camera.CoordinateFrame * CFrame.new(0,-2,-2) end)
Which puts a part in the screen so it sticks blah blah, and I want to rotate it so it's pointing at the mouse, because as of the code it just is pointing horizontally off the screen. What would I do for that?
Your solution is really simple. Just use the CFrame constructor CFrame.new(Vector3 position, Vector3 lookAt)
.
--get the correct positioning part.CFrame = Camera.CoordinateFrame * CFrame.new(0,-2,-2) --rotate it, keeping the position we just set part.CFrame = CFrame.new(part.Position, mouse.Hit.p)