local function CamCFrame(position, lookAt)
local lookVector = (position - lookAt).Unit
local modelUpVector = Vector3.new(0, 1, 0)
local rightVector = lookVector:Cross(modelUpVector)
local upVector = rightVector:Cross(lookVector)
return CFrame.fromMatrix(position, rightVector, upVector)
end
local camera = workspace.CurrentCamera
game.Players.LocalPlayer.CharacterAdded:Wait()
local character = game.Players.LocalPlayer.Character
workspace.House1.Door.ClickDetector.MouseClick:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
repeat wait(0.01)
camera.CFrame = CamCFrame(character.HumanoidRootPart.Position + Vector3.new(-1,-10,-10), character.HumanoidRootPart.Position)
until camera.CameraType == Enum.CameraType.Follow
end)
game.ReplicatedStorage.Folder.resetCameraAngle.OnClientEvent:Connect(function()
camera.CameraType = Enum.CameraType.Follow
end)
This script works fine, but the camera always looks in weird spots.
I don’t know why, but if I set it to (-1, 90, 0) it will look from the bottom and (-1, -10, -10) is the closest I can get to the angle I want.
The function is from one of the community tutorials.