Invalid argument #2 (string expected, got Instance) when using a string to get a tool name

hello im making a game and i am making the shop but i have some problems i get this error when i play

 Players.322ita.PlayerGui.Shop.MainFrame.ScrollingFrame.1.LocalScript:11: invalid argument #2 (string expected, got Instance)  -  Client - LocalScript:11

here is the script

    --Welcome Bois, set up this thing :) ~322ita
--did some changes now it gets the tool from the serverstorage not anymore from the folder i created before.
local CashValue = script.Parent.CashValue.Value --cash value
local plr = game.Players.LocalPlayer
repeat wait() until plr:HasAppearanceLoaded()
local ItNum = plr:WaitForChild("ItemNumber"):WaitForChild("ItemNum")
local itemNumber = script.Parent.ItemNumber
local itemName = script.Parent.ItemName
local button = script.Parent
local ld = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
local tool = game.ServerStorage[itemName]
dp = tool:Clone()
button.MouseButton1Click:Connect(function()
	print("clicked")
	button.BackgroundColor3= Color3(255, 24, 255)
	wait()
	button.BackgroundColor3 = Color3(255, 255, 255)
	--if ItNum.Value ~= itemNumber.Value then
	if ld.Value >= CashValue then
		print("purchased!")
			ld.Value = ld.Value - CashValue
			if plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary == true then
				local destroying = plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary.Parent
				destroying:Destroy()
			end
			wait()
			dp.Parent = plr.Backpack
		end
--	end
end)

It is because this line is instance.

local itemName = script.Parent.ItemName.Name

oh my bad thank u for my silly question :sweat_smile: i am a little bit stressed so…, anyway thx again

You have forgotten to add the NAME value to instance.

local itemName = script.Parent.ItemName.Name

anyway it was

local itemName = script.Parent.ItemName.Value

Why the Value though if you want the Name?

because on the value i have the name of the tool i want to get

You could’ve told us that originally that it was a value to shorten things up.

If the stringvalue is named Value then just put Value.Value

Modified code:

--Welcome Bois, set up this thing :) ~322ita
--did some changes now it gets the tool from the serverstorage not anymore from the folder i created before.
local CashValue = script.Parent.CashValue.Value --cash value
local plr = game.Players.LocalPlayer
repeat wait() until plr:HasAppearanceLoaded()
local ItNum = plr:WaitForChild("ItemNumber"):WaitForChild("ItemNum")
local itemNumber = script.Parent.ItemNumber
local itemName = script.Parent.ItemName
local button = script.Parent
local ld = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
button.MouseButton1Click:Connect(function()
	print("clicked")
	button.BackgroundColor3= Color3(255, 24, 255)
	wait()
	button.BackgroundColor3 = Color3(255, 255, 255)
	--if ItNum.Value ~= itemNumber.Value then
	if ld.Value >= CashValue then
		print("purchased!")
			ld.Value = ld.Value - CashValue
			if plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary == true then
				local destroying = plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary.Parent
				destroying:Destroy()
			end
			wait()
local tool = game.ServerStorage[itemName.Value]
dp = tool:Clone()
			dp.Parent = plr.Backpack
		end
--	end
end)

Hey! I modified your code, This will work probably.