Pickup message system

Hello developers i want to make a message when player pickups item, how to make it? I getting that:


and i using a local script

script:

local player = game.Players.LocalPlayer

wait(2)

player.Backpack.ChildAdded:Connect(function(child)
	local clone = player.PlayerGui.NewItems.Frame.Frame:Clone()

	print(child.Name.." added!")

	clone.Name = child.Name 
	clone.Parent = player.PlayerGui.NewItems.Frame
	clone.TextLabel.Text = "+"..child.Name
	clone.Visible = true
end)

i want to do it when player pickups item not when the item returns on player

Well from what I can see it looks like a tool, I think you can get this message by getting ChildAdded from the character and checking if the child is a tool. I added all the necessary explanations below.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() --//This gets the character

character.ChildAdded:Connect(function(child) --//This is fired whenever an instance is added into the character
	if not child:IsA("Tool") then return end --//This checks if the instance is a tool if it is not stops the rest of the code from running
	
	local clone = player.PlayerGui.NewItems.Frame.Frame:Clone()

	print(child.Name.." added!")

	clone.Name = child.Name 
	clone.Parent = player.PlayerGui.NewItems.Frame
	clone.TextLabel.Text = "+"..child.Name
	clone.Visible = true
end)

You’re going to need to cache tools to achieve this.

local player = game.Players.LocalPlayer
local cache = {}
wait(2)

player.Backpack.ChildAdded:Connect(function(child)
	if cache[child] then return end
	cache[child] = true
	local clone = player.PlayerGui.NewItems.Frame.Frame:Clone()

	print(child.Name.." added!")

	clone.Name = child.Name 
	clone.Parent = player.PlayerGui.NewItems.Frame
	clone.TextLabel.Text = "+"..child.Name
	clone.Visible = true
end)