when i press a button it will recover the name of a player enter a text area, then recover the id then change the skin (character) unfortunately it works but only for the vaitement and I do not know how to adjust the problem.
local Name = script.Parent.Parent.username.Text
local Id = game.Players:GetUserIdFromNameAsync(Name)
local Appearance = game.Players:GetCharacterAppearanceAsync(Id)
print(Id)
print(Name)
print(Appearance)
for i,v in pairs(plr.Character:GetChildren()) do
if v:IsA("CharacterAppearance") or v:IsA("Accessory") then
v:Destroy()
end
end
for i,v in pairs(Appearance:GetChildren()) do
v.Parent = plr.Character
end
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)