Main Character changing script is written in module and run by serverscript located in server script service
part of module:
local plrChar = plr.Character
char.PrimaryPart = char.HumanoidRootPart
char:SetPrimaryPartCFrame(plrChar.PrimaryPart.CFrame)
char.Name = plr.Name
if plrChar:FindFirstChild("Animate") and not char:FindFirstChild("Animate") then
plrChar.Animate:Clone().Parent = char
end
if plrChar:FindFirstChild("Health") and not char:FindFirstChild("Health") then
plrChar.Health:Clone().Parent = char
end
plr.Character = char
local rootPart = char:FindFirstChild("HumanoidRootPart")
local plrRoot = plr.Character:FindFirstChild("HumanoidRootPart")
if rootPart and plrRoot then
rootPart.CFrame = plrRoot.CFrame
end
for i, part in pairs(char:GetDescendants()) do
if part:IsA("BasePart") then
part.Anchored = false
end
end
the problem i am experiencing is that player is not attatched correctly with new character nor disappearing name of character for client
(blue = player cam position, red = character)
Ive tried configuring camera by local script
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = script.Parent:WaitForChild("Humanoid")
but this only fixed camera tracking to player
Summary
problem that character name shows even on player
new loaded character have really slow delay on animation with movements
way to optimize
extra points
character is loaded with insert service ( im considering this as problem but i need to keep it )
local IS = game:GetService("InsertService")
local Model = IS:LoadAsset(characterID)
Model.Parent = workspace
for _, Child in pairs(Model:GetChildren()) do
Child.Parent = Model.Parent
char = Child
end
Model:Destroy()
Usually roblox doesn’t let us rewrite the .Character property of the player, or well, it just doesn’t work as it should.
If you want to replace your character with another model, what you probably will have to do, instead of just rewriting the .Character property of the player to the new model, replace the parts of the current character with the new character.
In small words, delete all the parts in the current character, then clone all the parts of the character model you want to change to, and parent them back into the player’s character.
or… you could just clone the rig into starterplayer and name it ‘StarterCharacter’
and use this to set new char
local player = game.Players.LocalPlayer
function setChar(char)
local character = player.Character
local cf = character.HumanoidRootPart.CFrame
char.Archivable = true
local newChar = char:Clone()
newChar.Parent = game.StarterPlayer
newChar.Name = "StarterCharacter"
player:LoadCharacter()
newchar:Destroy()
newchar = nil
player.Character.HumanoidRootPart.CFrame = cf
player.Character.HumanoidRootPart:SetNetworkOwner(player)
player.Character.Humanoid.DisplayDistanceType = "None"
character:Destroy()
character = nil
end
--setchar(pathtocustomchar)
Optimisation: Make sure the character is already unanchored, but keep the root part anchored only.
Then you just need to do this: char.PrimaryPart.Anchored = false
I have a character-switching script somewhere, i’ll try find it and see why the nametag is appearing for you.
Tried the method deleting all things except humanoid inside default character and putting custom character
resulted unable to control even jumping and leg is clipping into floor just like platformstand (not enabled)
Module Script:
local plrChar = plr.Character
char.PrimaryPart = char.HumanoidRootPart
char:SetPrimaryPartCFrame(plrChar.PrimaryPart.CFrame)
if plrChar:FindFirstChild("Animate") and not char:FindFirstChild("Animate") then
plrChar.Animate:Clone().Parent = char
end
if plrChar:FindFirstChild("Health") and not char:FindFirstChild("Health") then
plrChar.Health:Clone().Parent = char
end
local rootPart = char:FindFirstChild("HumanoidRootPart")
local plrRoot = plr.Character:FindFirstChild("HumanoidRootPart")
if rootPart and plrRoot then
rootPart.CFrame = plrRoot.CFrame
end
for _, Child in pairs(plrChar:GetChildren()) do
if not Child:IsA("Humanoid") then
Child:Destroy()
end
end
plrChar.PrimaryPart = char.HumanoidRootPart
char:FindFirstChild("Humanoid"):Destroy()
for _, Child in pairs(char:GetChildren()) do
Child.Parent = plrChar
char = Child
end
char:Destroy()
for i, part in pairs(plrChar:GetDescendants()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(plr)
end
end