Help Change Player Character on button click (GUI) (CustomPlayerName)

You can use a HumanoidDescription to retrieve the appearance of any user. Keep in mind that you’ll need a RemoteEvent under ReplicatedStorage named “ChangeCharacter” for the following example to work.


LocalScript inside of your TextButton

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCharacter = ReplicatedStorage.ChangeCharacter

script.Parent.MouseButton1Click:Connect(function()
	ChangeCharacter:FireServer(script.Parent.Parent.username.Text)
end)

Script under ServerScriptService

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCharacter = ReplicatedStorage.ChangeCharacter

ChangeCharacter.OnServerEvent:Connect(function(Player, Name)	
	local UserId = Players:GetUserIdFromNameAsync(Name)
	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(UserId)
	local Position = Player.Character.PrimaryPart.Position
	
	Player:LoadCharacterWithHumanoidDescription(HumanoidDescription)
	Player.Character:MoveTo(Position)   -- Move the player back to their original position
end)
5 Likes