Camera doesn't follow character

I’ve got a custom character script, but for some reason, the camera doesn’t want to follow my character. I can move it freely, so as the camera (stuck in a place), but it just doesn’t want to follow where I go.
The scripts go like this:

-- CLIENT
local SystemRemote = ReplicatedStorage.Remotes.ArmorData
SystemRemote:FireServer({
	Reason = "ChangeChar"
})
Character = Player.CharacterAdded:Wait()
workspace.CurrentCamera.CameraSubject = Character:WaitForChild("Humanoid")
-- SERVER
ArmorData.OnServerEvent:Connect(function(Player,Data)
	print(Data.Reason)
	local Character
	if Data.Reason == "ChangeChar" then
		local OldCharacter = Player.Character
		local OldHRP = OldCharacter:WaitForChild("HumanoidRootPart")
		local NewCharacter = workspace:FindFirstChild("R15")
		Player.Character = NewCharacter
		Character = Player.Character
		Character.HumanoidRootPart.CFrame = OldHRP.CFrame
		OldCharacter:Destroy()
		print(Character:GetFullName())
	end
	local Humanoid = Character.Humanoid
	local Animator = Humanoid.Animator
	local ClothingFolder = Character.Clothing
	local Addons = Character.Addons
	if Data.Reason == "ArmorActivate" then
		Character.Normal.Parent = ClothingFolder
		Character.Pants.Parent = ClothingFolder
		Character.Muscles.Parent = ClothingFolder
		Character.Shirt.Parent = ClothingFolder
		ClothingFolder.Armor.Parent = Character
		for _, limb in pairs(Character:GetChildren()) do
			if limb:IsA('MeshPart') then
				limb.Color = Color3.fromRGB(255,255,255)
			end
		end
		Character.Head.Color = Color3.fromRGB(255,255,255)
		Character.Hair.Color = Color3.fromRGB(0,255,0)
		Character.Hair.Material = Enum.Material.SmoothPlastic
		Addons.OLetter.Transparency = 0.3
		Addons.GoldenArm.Transparency = 0
		Addons.ShieldArm.Transparency = 0
	end
end)


What should I do?

1 Like

Have you tried changing the Camera’s CFrame instead of the CameraSubject?

1 Like

I didn’t, but that would just change the position once; it wouldn’t follow the character. Right?

Try setting it to the primary part of your character instead of humanoid and see if that works. (I think the script might check for the humanoids parents primary part and if you haven’t set one I think it won’t work. Could easily be wrong though, I don’t usually use custom rigs and I can’t test right now).

And that suggestion would work, but you’ll need to bind it with run service to get it to update every frame.

I think it would be better to listen with GetPropertyChangedSignal() on the CFrame, but the thing is that it would still lag.


I however managed to fix it by completely changing the system I was swapping characters.

Change the CameraType to Enum.CameraType.Fixed and the CameraSubject to the PrimaryPart of your custom character.

2 Likes

When it comes to building stuff like custom camera controllers you want to use run service. That’s actually what the default Roblox scripts use. The reason why is because run service will make it update every frame before it renders (and tell you the time since the last update). I don’t know how frequently and when continuous property changes will actually call code, so that might work as well, but this type of use case is what RunService is for.

Though in your particular case actually just getting the camera subject changed correctly is far easier.