Changing character

im making a asymetrical horror game like forsaken and im trying to make it so that when the round starts the players are switched to their characters, this is my code so far but it doesn’t work
im posting the full script just in case
server script:

local playerCount = #game.Players:GetPlayers()
local plrs = game.Players:GetPlayers()

wait(1)

spawn(function()
	while true do
		wait(0)
		playerCount = #game.Players:GetPlayers()
	end
end)

while true do
	wait(1)
	if playerCount <= 0 then
		script.Parent.Time.Value = 60
	else
		script.Parent.Time.Value = script.Parent.Time.Value - 1
		print("a")
		if script.Parent.Time.Value == 0 then
			if workspace.inRound.Value == false then
				workspace.inRound.Value = true
				script.Parent.Time.Value = 240
				local players = game:GetService("Players"):GetPlayers()
				local killer = players[math.random(1, #players)]
				killer.Character.killer.Value = true
				local oldpos = killer.Character.HumanoidRootPart.CFrame --where character change starts
				local killercharacter = game.ReplicatedStorage["Butcher Files"].StarterCharacter:Clone()
				killercharacter.Name = killer.Name
				killercharacter.Parent = workspace
				killercharacter.HumanoidRootPart.CFrame = oldpos
				if killer.Character then
					killer.Character:Destroy()
				end
				killer.Character = killercharacter
				game.ReplicatedStorage.ChangeCamSubject:FireClient(killer, killercharacter) -- where it ends
				local folder = workspace:FindFirstChild("Killer Spawns"):GetChildren()
				print(folder)
				if #folder > 0 then
					local Killerspawn = folder[Random.new():NextInteger(1, #folder)]
					killer.Character:WaitForChild("HumanoidRootPart").CFrame = Killerspawn.CFrame * CFrame.new(0, 4, 0)
					print(Killerspawn)
				else
					print("No spawns!")
				end

				print(killer)
				for _, player in pairs(players) do
					if player.Name == killer.Name then continue end
					
					if player.Character and player.Character:FindFirstChild("survivor") then 
						player.Character.survivor.Value = true
					end
					print(player)
					local spawns = workspace:FindFirstChild("Survivor spawns"):GetChildren()
					if #spawns > 0 then
						local survivorspawn = spawns[Random.new():NextInteger(1, #spawns)]
						player.Character:WaitForChild("HumanoidRootPart").CFrame = survivorspawn.CFrame * CFrame.new(0, 4, 0)
						print(survivorspawn)
					else							
						print("No spawns!")
					end
				end
			else
				workspace.inRound.Value = false
				script.Parent.Time.Value = 50
			end
		end
	end
end

local script in starter character scripts:

game.ReplicatedStorage.ChangeCamSubject.OnClientEvent:Connect(function(killer, killercharacter)
	game.Workspace.CurrentCamera.CameraSubject = killer.Humanoid
end)

What error are you getting on the output? (I’m using a translator)

so instead of cloning the character, you might be able to use the characters humanoid to get the description and apply it.

local killer = players[math.random(1, #players)]
local killerCharacter = game:GetService("ReplicatedStorage"):WaitForChild("Butcher Files"):WaitForChild("StarterCharacter")
local playerCharacter = player.Character
playerCharacter:WaitForChild("Humanoid"):ApplyDescription(killerCharacter:WaitForChild("Humanoid"):GetAppliedDescription())

I think that might work? Let me know if that works

I’m not that unshocked to see that code…

You can use functions.
(make while true do and functions seperated)
you don’t need put client’s camera on other character, you just need to replace client’s character
you don’t need use ipairs or pairs in order to count players
you can just

for i,v in game:GetService("Players"):GetPlayers do

end

this kinda works but instead of changing the players appearence to be the characters appearence it makes them blank

local killercharacter = game.ReplicatedStorage["Butcher Files"].StarterCharacter:Clone()
killer.Character:WaitForChild("Humanoid"):ApplyDescription(killercharacter:WaitForChild("Humanoid"):GetAppliedDescription())

(“killer” is the player changing)

can you send a screenshot of how the killer rig is structured?