-
What do you want to achieve?
I have a custom character script that changes the players character by using
plr.Character = model
But when the player dies it switches back to the StarterCharacter
Is it possible for the player to keep the character it switched into?
-
What is the issue?
Here is the code for the character switching
local function respawnPlayer(plr, modelName, savelocal)
local model = game.Workspace:FindFirstChild(modelName)
local oldModel = plr.Character
local newModel = model:Clone()
newModel.Name = plr.Name
plr.Character = newModel
newModel.Parent = game.Workspace
for _, object in ipairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
local newObject = object:Clone()
newObject.Parent = game.Workspace:FindFirstChild(plr.Name)
end
newModel:SetPrimaryPartCFrame(game.Workspace.SpawnLocation.CFrame)
oldModel:Destroy()
game.Workspace:WaitForChild(plr.Name).Humanoid:UnequipTools()
if not savelocal then
return
end
savedata(plr, savelocal)
end
-
What solutions have you tried so far?
I have searched though multiple forums(including this one) and found nothing
I have also tried using CharacterRemoving but it detects when the player switches charcters and when the player dies