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.