How can I change the character to another character?

so I tried this inside playerscripts, and it didnt work, I then tried putting it in characterscripts, and while it did transfer control over to the new model, the camera remained fixed at were my old character was, is there a particular place I should be doing this at?

This problem feels like it was asked before so I hope my answer isn’t wrong, because I have currently no ways of testing this sorry.
You can use the :LoadCharacter() which reloads the character without killing him. And basically change the starter character then you playre:LoadCharacter().

4 Likes

I acually tried this beforehand but I believe I did it wrong, if not you could someone provide an example?

3 Likes

So basically here are the steps:

  1. The player would start with a character

  2. When the player wants to change his character to something else, you would remove the first character, and replace it with the new one he chose that was probably stored somewhere in serverstorage or replicatedstorage. And of course the character has to be name StarterCharacter

…,… image

  1. Then when you player:LoadCharacter() the old character would reload without being killed and will have the new startercharacter
2 Likes

but wont putting the new character in starterplayer make all players change into the new model?

1 Like

Well if you change the StarterCharacter from a localscript, then it would only change for the player with that local script.
Good note btw!

1 Like

alright, so, i had an issue with this in the past, where i wanted character models to be swapped when a certain condition was in place (i.e. pressing a button to morph you into some other character). what i ended up doing is a bit finicky and definitely should be avoided, but unless someone comes up and advises a better way, here’s how i handled it.

game script:

local StarterPlayer = game:GetService("StarterPlayer")
local ServerStorage = game:GetService("ServerStorage") --place your new chara model in here
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local event = Instance.new("RemoteEvent")
event.Name = "modelswapevent"
event.Parent = ReplicatedStorage

--leave bits out with oldmodel if you don't have StarterCharacter in StarterPlayer
event.OnServerEvent:Connect(function(charamodelname, player)
	local oldmodel = StarterPlayer.StarterCharacter
	local charamodel = ServerStorage:FindFirstChild(charamodelname)
	newcharamodel = charamodel:Clone()
	newcharamodel.Name = "StarterCharacter"
    oldmodel.Parent = nil
	newcharamodel.Parent = StarterPlayer
	player:LoadCharacter()
	newcharamodel:Destroy()
	oldmodel.Parent = StarterPlayer
end)

local script:

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage.modelswapevent
-- insert code here or w/e
event:FireServer("modelname")

like i said, my method is likely a bit more complicated than it needs to be, but what it does is it quickly swaps out the starter character model for the one you’d like to turn into temporarily – for a SPLIT second.

12 Likes

This isn’t proper usage of StarterCharacter. You shouldn’t ever, really, be using StarterCharacter to switch out characters. It works but it’s an unsupported hack.

7 Likes

do you have a method that could work as a solution?

Yeah I was deffintley sure that I was wrong! Sorry for the false information.
I wanted to try this out but studio isn’t available for me at the moment.

I unfortunately don’t and changing out characters is an issue I’ve been struggling with for well over a few years by now. My most recent thread regarding it was some months ago.

2 Likes

i’ve also been struggling with it for years and the hacky/not good way i’ve described earlier in this thread is the closest i have been able to accomplishing what i wanted. i hate using the method and would rather use something that isn’t as “beat-around-the-bush” in nature.

2 Likes

I believe I found a solution to this ongoing problem. first here is what I did:

this is what you will need.
chartestimage

localscript:

wait(3)
local plr = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local rig = game.Workspace.TestRig
camera.CameraType = "Follow"
camera.CameraSubject = rig.HumanoidRootPart
script.Parent.RemoteEvent:FireServer()

normal script:

local dontrepeat

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)

local char = plr.Character
local rig = game.Workspace.TestRig --the model you want to turn into--



if not rig.HumanoidRootPart:FindFirstChild("DontRepeat") then
	plr.Character = rig
end
wait()
if not rig.HumanoidRootPart:FindFirstChild("DontRepeat") then
dontrepeat = Instance.new("Attachment")
dontrepeat.Name = "DontRepeat"
dontrepeat.Parent = rig.HumanoidRootPart
wait()
char:Destroy()
end
end)

setting the players character to a new rig does work however the camera does not change and will become locked in empty space, so I changed the camera to the new rig inside a localscript. and I set the players character from a normal script.
I put this folder inside startergui because the remote event wont work inside playerscripts.
and in doing so this folder gets cloned when the character is changed, so I used an attachement to tell the game that the new model has already been changed. so if it finds this attachment it wont fire again. I ran this once successfully but you can change it to your liking. I hope this helps anyone who is having trouble with changing custom characters.

59 Likes

I have a question where did you put the folder, in serverscript or in replicated or what?

2 Likes

When I used his solution, I was unable to get it to work. I do not remember where that folder was meant to go, but I do have another solution.

This one starts off with a local script under the starterGUI. For mine I made it so that when a button is clicked it changes your character, but all you need is a remote event to fire from the client. You can link this up to anything in your game.

function OnClick()
	local model = putwhereveryourmodelishere
	assert(model, "model does not exist for this location!")

	game.ReplicatedStorage.respawnEvent:FireServer(model.Name) --Fires an event named "respawnEvent" to the server. Name this to your event.
end

script.Parent.MouseButton1Click:Connect(OnClick)

To get this to work all you need is to tell the server which character to change the player to.

Here is the server script that receives the message and changes the player. I put mine in server script server to keep it cleaner, but it should work anywhere.

replicatedstorage = game:GetService("ReplicatedStorage")
respawnEvent = replicatedstorage.respawnEvent
local dontrepeat

local function respawnPlayer(plr, modelName)
	local model = replicatedstorage.Characters:FindFirstChild(modelName) -- I have all of my models in a folder named character, this is how the server finds them.
	print("Model from client is", model) -- This print is unnecessary, but useful for debugging
	if not plr.Character.HumanoidRootPart:FindFirstChild(modelName) then -- Check to see if the player is already a different model
		local oldModel = plr.Character
		local newModel = model:Clone()

		local oldCFrame = oldModel:GetPrimaryPartCFrame()

		plr.Character = newModel
		newModel.Parent = workspace -- this follows current character loading behavior
		newModel:SetPrimaryPartCFrame(oldCFrame)
		oldModel:Destroy()
		dontrepeat = Instance.new("Attachment")
		dontrepeat.Name = modelName
		dontrepeat.Parent = newModel.HumanoidRootPart
		wait()
	end
end
respawnEvent.OnServerEvent:Connect(respawnPlayer)

I believe this should work. If you have any issues or questions then hmu

6 Likes

I know this is a little old but it’s really effective. Thanks man. :slight_smile:

1 Like

I made a seperate post with a save file showing a cleaner way to make custom characters since this post got a lot of attention:

the solution has been found !

local function change_character(player_)
	local starter_player = game.StarterPlayer
	
	-- delete OLD characters
	local old_character = starter_player:FindFirstChild("StarterCharacter")
	if old_character then 
		old_character:Destroy() 
	end
	
	-- create and move the NEW character to the DESIRED location
	local new_character_model = game.ReplicatedStorage["StarterCharacter_NEW_1"]:Clone()
	new_character_model.Name = "StarterCharacter"
	new_character_model.Parent = starter_player
	
	-- restart the сharacter
	player_:LoadCharacter(new_character_model)	
	
	-- !!! when used LoadCharacter(), the character will always be selected from "game.StarterPlayer."
end
4 Likes

Thank you so much, I was looking for this for ages!

1 Like

Thanks. Helped me on my Commission years later!