Humanoid.CameraOffset not changing

Hello, developers!

So I was making a table camera viewing where you view under tables. But for some unknown reasons, The camera offset won’t change.

local RunService = game:GetService("RunService")
local TableCamEvent = game.ReplicatedStorage.TableCamEvent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:FindFirstChild("Humanoid")

local isHiding = false

if char then return end
TableCamEvent.OnClientEvent:Connect(function()
	if not isHiding and humanoid.Health >= 0 then
		humanoid.CameraOffset = Vector3.new(0, -2, 0)
	elseif isHiding then
		humanoid.CameraOffset = Vector3.new(0, 0, 0)
	end
	isHiding = not isHiding
end)

Note that the code is a local script and a server-script fires the remote event.

Make sure that the Camera.CameraSubject is set to the Player Character’s humanoid, or else it wouldn’t work…

The camera subject is already sat to the humanoid, and also there are no errors or warnings in the output.

have you tried print debugging or maybe just change the camera type to scriptable so you can add custom behaviour like changing the cframe if you want.

I cannot exactly determine the problem, the breakpoints I inserted were just pointing to an unlikely line of code which is odd.

Maybe try just adding print statements on each line then adn see which one doesn’t print. Maybe going the old way is better.

Maybe the remote event isn’t being fired. I don’t see any problems.

The remote event is fired, but the camera offset won’t change and no errors or warnings.

I removed a line of this code: if char then return end, and tested it, And it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.