Changing Player Avatar

I’m currently trying to make a script where if I press “E” then the player’s avatar will be replaced with a custom character model I made. I tested out the character model by renaming it to StarterCharacter and placing it in StarterPlayer, and it works. However now I’m not exactly sure how to implement what I originally wanted since the script I made doesn’t work, and I did some research and people said that StarterCharacter only takes effect on your first join.

So how exactly do I do this? (Press “E” to change my player’s character to my custom character)

Here is the local script I have:

local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local CubeShiftEvent = RS:WaitForChild("CubeShiftEvent")
local model = game.ReplicatedStorage.StarterCharacter
local player = game.Players.LocalPlayer

UIS.InputBegan:Connect(function(input,gameProcessed)
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			if input.KeyCode == Enum.KeyCode.E then
				local newAv = model:Clone()
				newAv.Parent = game.StarterPlayer
				CubeShiftEvent:FireServer(model)
			end
		end
	end
end)

And here is the server script I have:

local RS = game:GetService("ReplicatedStorage")
local CubeShiftEvent = RS:WaitForChild("CubeShiftEvent")

CubeShiftEvent.OnServerEvent:Connect(function(player, model)
	player:LoadCharacter()
end)

The part that goes wrong (or technically doesn’t go wrong since a StarterCharacter model only affects newly joins) is that when I press E, the StarterCharacter model gets cloned and placed into StarterPlayer, and I get reloaded but my avatar is still the same.

So basically thats my main problem and concern. Being able to change my player’s character to a custom character while not changing other player’s characters.

Hey there! Don’t get confused too much, you just change the Player.Character property of any player to change his avatar. But do remember to change the camerasubject of the client’s camera as well!

Well I did try doing player.Character = model but nothing happened

this is what i know, changing player’s humanoid description
sorry if this makes an error, i don’t use autofill to make this

--//constraits
local lp = game.Players.LocalPlayer
local next_character = nil --change to the character instance
--//services
local uis = game:GetService('UserInputService')

uis.InputBegan:Connect(function(key)
if key == Enum.KeyCode.E then
local character1 = lp.Character
local hum = character1:WaitForChild('Humanoid')
local character2 = next_character:WaitForChild('Humanoid'):GetAppliedDescription()
hum:ApplyDescription(character2)
end
end)

That is probably because your model exists either in the server storage or on the replicated storage, i would advice you to first clone the model and then set the clone’s parent to game.workspace and then set it as the Player’s Character.

i don’t recommend changing the player’s character by the model

Well when I do that this happens:
https://streamable.com/uqiekw

you can change the player’s camera subject to the new character humanoid and set the camera mode to attach

What about the other avatar that respawns?

just change again when it died ofcourse?

yes, but I got confused because in the Humanoid Description Webpage it was said that using customely edited character may cause ‘undefined behaviour’ that is why I opted for the second option of setting the player’s Character.

Following this, the shapeshifting now works, but the camera focuses back on the old avatar since it respawns shortly after.
https://streamable.com/oyf260

do it again when the player dies

Disable autoloads in Players then it’s done, but if your character is not spawning, just load the character by :LoadCharacter since it doesn’t auto load.

This thread might be of some help to you:
Are there any methods of cleanly swapping character models from default rigs to custom character constructs? - Help and Feedback / Scripting Support - DevForum | Roblox

This thread doesn’t quite have a solution tacked to it, rather the suggested way is pretty complicated and weird; it’s not completely clean. Character support is really bad so trying to change the model from a standard rig is usually very hacky.

The only thing, despite this, that I do not recommend is misusing StarterCharacter to change characters because that’s not how it’s intended to be used. StarterCharacter is only meant to change the way rigs are constructed for the lifetime of the game, not for one player.

1 Like