Cannot change name of old model after switching Player character

Hello. I was writing a system that allows you to switch character models on a whim. It works completely fine. However, within the script is one line that refuses to work with me. That is changing the name of the old model. I cannot fathom why Roblox still believes the old model is the player character.

-- The current identity (2) cannot set a Character's name (lacking permission 4)

The new model has their name changed before the player gets the character, allowing that to work perfectly. I’ve tried to ignore/reposition specific lines of code but I’ve made no progress doing so. This is part of my module that switches character models.

local Part = model:FindFirstChildWhichIsA("BasePart",true)
	assert(Part,"NO VALID PARTS FOUND IN MODEL, CANNOT SWITCH CHARACTER")
	
	local OldChar = plr.Character
	if model == OldChar then return end
	
	-- New
	model.Name = plr.Name
	plr.Character = model
	
	Part:SetNetworkOwner(plr)
	for _,v in pairs(OldChar:GetDescendants()) do
		if not v:IsA("Script") then continue end

		local OldPar = v.Parent.Name
		local NewPar = model:FindFirstChild(OldPar,true) or model

		v.Parent = NewPar
	end
	
	-- Change Camera
	SCam:FireClient(plr,"CameraSubject",model)
	
	if destroyOldModel then OldChar:Destroy() else
		OldChar.Parent = workspace
		local OPart = OldChar:FindFirstChildWhichIsA("BasePart",true)
		OPart:SetNetworkOwner()
		CS:AddTag(OldChar,"CanControl")
		OldChar.Name = "Rig"
	end

I’ve been stuck at this roadblock. I haven’t been able to find a solution to this on the development forums either, considering that I was naming the old model AFTER I changed the Player’s Character. This is a video of how the system works. Very self-explanatory.

1 Like

A hacky solution is to instantly swap out the players character when they spawn. Might have something to do with coregui scripts which put priority on that specific model as always being the players character no matter what, evidence of it being coregui mainly revolves around the “lacking permission 4”

I was thinking that it may not be replicating via the client, and errors out because of that.

I think that the player in there actual player Instance has a property called character so if you set that to the new character that should work

Yes. That’s exactly what you change to change the player’s character. The problem is that the server is still treating the old character as the current character, which gives me this problem. I’m uncertain if this is an intentional Roblox feature.

well are you doing it on a local script or on a server script?

The game wouldn’t update to others if I didn’t do this via a server-script.