Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Custom Camera Script is Not Working, Argument 3 Missing?

I followed the wiki on how to create a custom camera script and it seems it isnt working. I was wondering if anyone here could help me out a little.

Here is the code

local cameraHeight = 12
local cameraZOffset = 20
local cameraXChase = 10
local cameraSpeed = .25

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')

local function setupCamera()
	camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset), Vector3.new(0,cameraHeight,0))
end

setupCamera()
player.CharacterAdded:connect(setupCamera)

local function onUpdate()
	if player.Character and player.Character:FindFirstChild('Torso') then
		local playerX = player.Character.Torso.Position.X
		local cameraX = camera.CFrame.p.X
		
		if cameraX - cameraXChase < playerX then
			camera.CFrame = camera.CFrame + Vector3.new(cameraSpeed, 0, 0)
		end
	end
end

RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate())

Its a LocalScript under StarterPlayer.StaterPlayerScripts. And its like its not finding the torso.

The output says at line 28 (The last line after end) It says Argument 3 missing or nil? I have never had this before?

1 answer

✓ Accepted answer
RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)

This discussion is preserved as it was. New answers, comments, and votes are closed.