I want to make a camera controller similar to Nullwork (or this). Basically the camera is locked at one position, but tracks the player’s character.
Script
local part = workspace:WaitForChild("TestPart")
local cam = workspace.CurrentCamera
local rs = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local enabled = script.Enabled
-- local ts = game:GetService("TweenService") will use later
repeat
wait()
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
local function update()
local cframe = CFrame.lookAt(part.Position, char:WaitForChild("HumanoidRootPart").Position, Vector3.new(0,0,0))
cam.CFrame = cframe
end
rs:BindToRenderStep("UpdateCamera", Enum.RenderPriority.Camera.Value + 1, update)
enabled.Changed:Connect(function(bool)
if bool then
rs:BindToRenderStep("UpdateCamera", Enum.RenderPriority.Camera.Value + 1, update)
else
rs:UnbindFromRenderStep("UpdateCamera")
repeat
cam.CameraType = Enum.CameraType.Follow
until cam.CameraType == Enum.CameraType.Follow
end
end)
The script set the CameraType to Scriptable, calculates the cframe, and does nothing (No errors),
but i’m a bit skeptical about these NAN values when printing the CFrame