Spawning in as custom character kills me?

Hey there! I’m trying to make it so you can spawn in as a custom character, however when I do spawn in it kills me for some reason? (Yet the character model still stays there and still does the idle anim.)

game.ReplicatedStorage.Event.Deploy.OnServerEvent:Connect(function(plr)
	local charmodelF = game.ServerStorage.Characters:GetChildren()[math.random(1,#game.ServerStorage.Characters:GetChildren())]
	local charmodel = charmodelF.StarterCharacter:Clone()
	local oldC = plr.Character
	for v,r in pairs(oldC:GetChildren()) do
		if r:IsA("Script") or r:IsA("LocalScript") then
			r.Parent = charmodel
		end
	end
    charmodel.Name = plr.Name
    plr.Character = charmodel
    charmodel.Parent = workspace
	charmodel:SetPrimaryPartCFrame(workspace.Spawn.CFrame+Vector3.new(0,5,0))
	charmodelF:FindFirstChildWhichIsA("Tool"):Clone().Parent = charmodel
	--oldC:Destroy()
end)

Video of whats happening:

I’m still able to move around as that charater but the GUI resets and the death ring still appears.

Thanks for any help!

try cloning the scripts to the player instead of directly changing their parent
So like

r:Clone().Parent = charModel
also make sure you set the parent of character to workspace before you do
plr.Character = newChar

Nope, that did not fix it…

write it like this:

game.ReplicatedStorage.Event.Deploy.OnServerEvent:Connect(function(plr)
	local charmodelF = game.ServerStorage.Characters:GetChildren()[math.random(1,#game.ServerStorage.Characters:GetChildren())]
	local charmodel = charmodelF.StarterCharacter:Clone()
	local oldC = plr.Character
	for v,r in pairs(oldC:GetChildren()) do
		if r:IsA("Script") or r:IsA("LocalScript") then
			r:Clone().Parent = charmodel
		end
	end
    charmodel.Name = plr.Name
    charmodel.Parent = workspace

    plr.Character = charmodel
     
    for _, v in pairs(plr.Character:GetChildren()) do
          if v.ClassName:match("Script") then
               v.Disabled = true
               v.Disabled = false
          end
    end
    
	charmodel:SetPrimaryPartCFrame(workspace.Spawn.CFrame+Vector3.new(0,5,0))
	charmodelF:FindFirstChildWhichIsA("Tool"):Clone().Parent = charmodel
	oldC:Destroy()
end)

Does not work with that code either.

Is it something with the character? I’ve looked at other posts here and it seems to work for them…

Does your head to torso weld get removed/broken when you spawn in? That’ll kill your character.

It does not exactly “kill it”, the GUI just resets and the death border ring shows up.
The character still stays there.
(Watch the video on the OG post.)

Still have no idea why this is happening…

when this part is ran

everything gets refreshed (stuff in playergui, backpack, etc) making the localscripts inside run from scratch; so thats why you see the gui again when character is changed. to change this i suggest setting the localscripts inside your starterpack/startergui to make sure when the character is the newer character model it doesnt run and dont display the ui as well

Ah ok, that makes more sense, thank you.