Camera wont follow the players character when it's changed

I made a character select menu and it works fine until the player spawns in.
Once the player spawns it the camera just stays in place for some reason, here code

RS:WaitForChild("SpawnCharacter").OnServerEvent:Connect(function(plr21,Character)
			plr21:LoadCharacter()
			local NewCharacter = Character:Clone()
			NewCharacter.Name = plr21.Character.Name
			NewCharacter.Parent = workspace
			NewCharacter:SetPrimaryPartCFrame(plr21.Character.PrimaryPart.CFrame)
			plr21.Character = NewCharacter
		end)

the server-side script that changes the character is above.
This is a video if that helps
robloxapp-20220312-1438211.wmv (2.7 MB)

Maybe put it in the workspace after you make it your character

RS:WaitForChild("SpawnCharacter").OnServerEvent:Connect(function(plr21,Character)
	plr21:LoadCharacter()
	local NewCharacter = Character:Clone()
	NewCharacter.Name = plr21.Character.Name
	NewCharacter:SetPrimaryPartCFrame(plr21.Character.PrimaryPart.CFrame)
	plr21.Character = NewCharacter
    NewCharacter.Parent = workspace
end)
4 Likes

This is likely because the CameraSubject is still your old character. Try updating workspace.CurrentCamera.CameraSubject = NewCharacter.Humanoid (assuming NewCharacter has a Humanoid; if it doesn’t, use NewCharacter.PrimaryPart)

1 Like

How would i get current camera when i’m doing it in a Server script

CurrentCamera is intended to be used in and may only work in a LocalScript, so it’s still workspace.CurrentCamera. However, you’ll need to get the new character from your LocalScript.

Wait bloxydev’s suggestion worked, it’s fixed now. How come?

Roblox may automatically update the CameraSubject in that case, I wasn’t sure. If your new character wasn’t parented to Workspace (which now that I look at it, it wouldn’t have been since you were cloning it), the camera would not be able to go to it because it wouldn’t exist in 3D space until it’s in Workspace.

1 Like

Well, no it was in the workspace, but it was in the workspace before i change the players character

Took a look at your code again and I see what you mean. Might be some Roblox bugginess or you forgot to put it back in your real script, not sure.

1 Like