25: invalid argument #3 (Instance expected, got string)

Well, I am trying to make a menu of food ingredients (of ingredients that you have stored in your ProfileService data), and then when trying to obtain that ingredient data, I got the error in the title. I’m using ProfileService, and when I want to get that data that I mentioned earlier, it only lets me get one of the data, which is basically the number of stacks of the object, it doesn’t let me get the name and that’s when it gives me the error

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")

local DataManager = require(game.ServerScriptService:WaitForChild("DataStore"):WaitForChild("Configurations"):WaitForChild("DataManager"))

local Proximity = script.Parent:WaitForChild("DoorRefrigerator"):WaitForChild("ProximityPrompt")

	local Profile = DataManager:Get(player, true)
	local Player_Gui = player.PlayerGui
	local Backpack = player.Backpack
	local Menu_de_mapa = Player_Gui:WaitForChild("MenuDeMapa")
	local Objects = Menu_de_mapa:WaitForChild("Objects")
	local Sample = Objects:WaitForChild("Script"):WaitForChild("Sample")

	for _, GetObjects in pairs(Profile.Data.Other_objects_and_tools.Food_from_refrigerator) do
		if GetObjects.Stacks > 0 then
			local Object = Sample:Clone()
			Object:WaitForChild("ImageLabel"):WaitForChild("Stack").Visible = true
			Object:WaitForChild("ImageLabel"):WaitForChild("Stack").Text = GetObjects.Stacks
			Object:WaitForChild("Item").Value = GetObjects.Name
			Object.Parent = Objects:WaitForChild("ScrollingFrame")
	Objects.Visible = true

These are the data of the ProfileService that I want to get

local Players = game:GetService("Players") 
local ProfileService = require(script:WaitForChild("ProfileService"))
local saveStructure = {
	Other_objects_and_tools = {
		Food_from_refrigerator = {Meat = {Stacks = 5, Name = "Meat"}, Bread = {Stacks = 3, Name = "Bread"}};

Which line spits out the error? I’m guessing this line:

Object:WaitForChild("Item").Value = GetObjects.Name

Because it is trying to put a string (the name) into Item’s value. If that is the case, is Item by chance an ObjectValue?

Sorry, sometimes it stressed me too much that I don’t even pay attention to the details, and it was an ObjectValue, I confused it with a StringValue

1 Like

We’ve all been there! Thankfully the description of the error tells us what to look for, and usually where. The “got” is on the right half of the equation, and the “expected” is the ask, on the left side.

If instance and string were swapped, for example, I would immediately inspect the object type of “Stacks.”

Add a .Name property after the object reference and you’ll be good to go.