How do I make proper player camera adjustments to avatars of extremely small scale

Hi there, I’m working on trying to get a workspace-sided script to work that basically shrinks the player down upon joining and slowly grows them up to bigger sizes infinitely. However, every time they do get shrunk their camera cannot attach to the player head as usual and it kind of ruins the effect of being shrunk down to a small size which is what I’m trying to fix. I’ve tried changing the camera FOV for the player via game.Workspace.Camera but it doesn’t seem to work.

Code in question:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local cam = game.Workspace.Camera
		local noid = char:FindFirstChild("Humanoid")
		if noid ~= nil then
			
			wait(0.1)
			local HS = noid.HeadScale
			local BDS = noid.BodyDepthScale
			local BWS = noid.BodyWidthScale
			local BHS = noid.BodyHeightScale
			print("Initial Camera FOV: "..cam.FieldOfView)
		
			HS.Value = HS.Value * 0.1
			BDS.Value = BDS.Value * 0.1
			BWS.Value = BWS.Value * 0.1
			BHS.Value = BHS.Value * 0.1
			noid.WalkSpeed = noid.WalkSpeed * 0.1
			cam.FieldOfView = cam.FieldOfView * 0.1
			while noid ~= nil do
				wait(1)
				
				HS.Value = HS.Value * 1.01
				BDS.Value = BDS.Value * 1.01
				BWS.Value = BWS.Value * 1.01
				BHS.Value = BHS.Value * 1.01
				noid.WalkSpeed = noid.WalkSpeed * 1.01
				print("Walkspeed: "..noid.WalkSpeed)
			end
		end
	end)
end)

Any help would be appreciated.

1 Like

I think you want to change the Humanoid.CameraOffset of the character’s Humanoid. This can be used to move the focal point of the camera up and down.

2 Likes

Tried implementing the method you stated by substituting with these two lines:

local cam = noid.CameraOffset

cam = cam + Vector3.new(0,-1.5,0)

No errors/warns, it isn’t changing though. Could you give a code example or explain further?

1 Like

You need to store a reference to the Humanoid to change it’s properties. For example:

local part = Instance.new("Part")
part.Position = Vector3.new(1,0,0)
local position = part.Position
position = Vector3.new(0,0,0)

print(part.Position.X)
print(position.X)

Result:

1
0

Notice how the position of the part doesn’t change. This is because you need to store a reference to the Part, then change the position. Storing the part’s Position property stores the value, not a reference to the Position property.


In your case, you just need to do

noid.CameraOffset = Vector3.new(0,-1.5,0) -- Probably set the property, not increment, since it should be the same each time the humanoid is scaled.

You’ll also need to calculate the desired position. I think the formula for the Y component is -1.5+bodyHeightScale*1.5.

Also note that I believe Humanoid.CameraOffset has to be changed on the client.

1 Like