How to Fix Player's New Character Camera?

Hi, I am working on a game and I am trying to change a Player’s Character Mid-Game (kinda like piggy)
and I have done it, but there is something strange going on with the camera of the player so when I change the player’s character the camera stays at the old character’s position.

Here is my code that changes the player’s character:

local Players = game:GetService("Players")
local status = game:GetService("ReplicatedStorage").Information
local mummychar = game.ServerStorage.Mummy:Clone()

while true do
	
	local Countdown = 15 -- intermission, make this as long as you want
	
	repeat wait(1)
		Countdown = Countdown - 1
		
		status.Value = 'Intermission : '..Countdown
	until Countdown <= 0
	
	local mummy = Players:GetChildren()[math.random(1, #Players:GetChildren())]
	
	status.Value = mummy.Name.." Is The Mummy!"
	
	wait(5)
	
	mummychar.Parent = workspace
	
	mummy.Character.Humanoid.Health = 0
	mummy.Character.Humanoid.Died:Connect(function()
		mummy.Character = mummychar
	end)
	
end

And here is a video of the glitch:

robloxapp-20200926-1334562.wmv (2.9 MB)

I don’t know how to fix this, so if you could please help me that would be great, thanks!

1 Like

You just add:

Camera.CameraSubject = player.Character.Humanoid

this should fix the issue

if it is still not working, you can try doing this:

local MAX_ATTEMPTS = 10
local ATTEMPTS = 0
repeat
wait()
Camera.CameraSubject = player.Character.Humanoid
ATTEMPTS += 1
until Camera.CameraSubject == player.Character.Humanoid or ATTEMPTS == 10

it will try overriding the camera 10 times, before stopping, doing it repeatedly will cause a crash.

3 Likes

Thanks, but how do I access the player’s camera (sorry I’m not the best at scripting)

in a local script, type:

local camera = workspace.CurrentCamera
1 Like

I believe this is not the correct way to change a player’s character.
You should do this:

local Players = game:GetService("Players")
local status = game:GetService("ReplicatedStorage").Information

while true do
	
	local Countdown = 15 -- intermission, make this as long as you want
	
	repeat wait(1)
		Countdown = Countdown - 1
		
		status.Value = 'Intermission : '..Countdown
	until Countdown <= 0
	
	local mummy = Players:GetChildren()[math.random(1, #Players:GetChildren())]
	
	status.Value = mummy.Name.." Is The Mummy!"
	
	wait(5)

    local newMummy = game.ServerStorage.Mummy:Clone()
	newMummy.Parent = game.Workspace
    newMummy.Name = mummy.Name

    mummy.Character = newMummy
	
end
2 Likes

just to add something, to change character, the new character must also have the same name as player.Name

2 Likes

Yeah, I know I forgot about it, let me edit it thanks