When you write the name of a player then the name of a dummy in the chat, the dummy takes on the appearance of this one

hello, I will need help for a script because I don’t know how to script at all, I don’t know anything about it.
I would like that when someone writes in chat “/(PlayerName) Dummy”
it changes the appearance of the dummy with the player appearance.
I tried to do it with an artificial intelligence and it gave me this

local player = game.Players.LocalPlayer
local chat = game:GetService("Chat")
local chatService = game:GetService("ChatService")
local chatEvents = chatService:GetPropertyChangedSignal("ChatEvents")
local dummy = workspace.Dummy

local function getPlayerAppearance(player)
	local character = player.Character
	if not character then return end
	local appearance = {}
	for i,v in next, character:GetDescendants() do
		if v:IsA("Shirt") or v:IsA("Pants") then
			appearance[v.Name] = v.ShirtTemplate or v.PantsTemplate
		elseif v:IsA("Accessory") then
			appearance[v.Name] = v.Handle.AccessoryWeld.C0
		elseif v:IsA("Hat") and v.Handle then
			appearance[v.Name] = v.Handle.HatAttachment.C0
		end
	end
	return appearance
end

local function setPlayerAppearance(dummy, appearance)
	local character = dummy.HumanoidRootPart.Parent
	if not character then return end
	for i,v in next, character:GetDescendants() do
		if v:IsA("Shirt") or v:IsA("Pants") then
			v.ShirtTemplate = appearance[v.Name] or v.ShirtTemplate
			v.PantsTemplate = appearance[v.Name] or v.PantsTemplate
		elseif v:IsA("Accessory") then
			v.Handle.AccessoryWeld.C0 = appearance[v.Name]
		elseif v:IsA("Hat") and v.Handle then
			v.Handle.HatAttachment.C0 = appearance[v.Name]
		end
	end
end

local function changeDummyAppearance(playerName)
	local player = game.Players:FindFirstChild(playerName)
	if not player then return end
	local appearance = getPlayerAppearance(player)
	if not appearance then return end
	setPlayerAppearance(dummy, appearance)
end

chatEvents:Connect(function(propertyName)
	if propertyName ~= "ChatEvents" then return end
	for i,v in next, chatService.ChatEvents:GetChildren() do
		if v.Sender:IsA("Player") and v.Sender == player and v.Message:match("%S+%s%S+") then
			local name, dummyPlayer = v.Message:match("(%S+)%s(%S+)")
			if dummyPlayer ~= "Dummy" then return end
			changeDummyAppearance(name)
		end
	end
end)

and when we redo the command it deletes the old appearance and it puts back that of the new player.
Thanks, you can also add me in discord if i need more help so i don’t have to Open a new Topic! :slight_smile: