Custom GUI ID accessory giver

You can write your topic however you want, but you need to answer these questions:

  1. I want to make a custom accessory giver using a GUI, here is a picture:
    image
    What I exactly want is when the user pastes or writes the accessory ID and press the send button, will get the accessory equipped.

  2. I tried this script:

local textBox = script.Parent.Search
local btn = script.Parent.Send

local iderror = script.Parent.IDerror

local function onButtonClicked()
	local accessoryId = tonumber(textBox.Text)


	if accessoryId then
		local player = game.Players.LocalPlayer
		local character = player.Character or player.CharacterAdded:Wait()


		local accessory = Instance.new("Accessory")
		accessory.Name = "CustomAccessory"
		accessory.Parent = character.Head


		accessory.AccessoryId = "rbxassetid://" .. accessoryId
	else
		
		iderror.Visible = true
		wait(3)
		iderror.Visible = false
	end
end

btn.MouseButton1Click:Connect(onButtonClicked)

But it’s not working, when I run it, it appears this on the output, and I don’t know what to do.

  1. I have searched on the dev forum, but the only topic related, was no useful for me.

If anyone is willing to help me, I would really appreciate it!

This is the GUI structure:
image