Type is not a valid member of StringValue-- Error

i change the variable of intval to stringval and still same message on that Type isnt a valid member of StringValue

local applevalue = game.Workspace.StockmarketValues.Apple.Value
local breadvalue = game.Workspace.StockmarketValues.Bread.Value
local fishvalue = game.Workspace.StockmarketValues.Fish.Value
local mixvalue = game.Workspace.StockmarketValues.Mix.Value

while true do
	wait(10)

local lottab = game.Workspace.Lots:GetChildren()


local appltab = {1}
local breatab = {1}
local fishtab = {1}

		for i,v in pairs (lottab) do
			if v.Type.Value == 1 then             **-------LINE 17 ERROR HERE!**
				table.insert(appltab,1,1)
			end
			if v.Type.Value == 2 then
				table.insert(breatab,1,1)
			end
			if v.Type.Value == 3 then
				table.insert(breatab,1,1)
			end
		end
	applevalue = 20 / (table.getn(appltab))
	breadvalue = 20 / (table.getn(breatab))
	fishvalue = 20 / (table.getn(fishtab))
	mixvalue = math.random(2,20)
	
	
	
			     -- Here im just resetting all tables to nil for the next loop
	
 	appltab = nil
 	breatab = nil
 	fishtab = nil
	
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

v appears to be a StringValue. Type is not a valid member of the StringValue object. Unless there is a Type object directly under v, I would remove Type. However, even then, you’re trying to interpret an integer. In that case, you most likely don’t have an IntValue under the children in lottab called “Type.”

i dont understand what you mean, but here is what i have.

The PRINTER script is very similar but i dont know why im getting the error in the other script if its working here?

I think the issue is that you try to find the Type object right after getting all the children of the Lots folder
Maybe add a WaitForChild or FindFirstChild for the Type object

if v:WaitForChild("Type").Value == 1 then 
     table.insert(appltab,1,1)
end

infinite yeild possible

Maybe the Type object doesn’t even exist?
In the other screenshot you showed the “Lot” object, but here it’s called “surfdudecally”, so maybe it’s missing the Type object, or has two of them?

Infinite yield is just a warning. Add the second argument (a number) to silence it (which is the timeout argument)

v:WaitForChild("Type", 5)

i find that strange too that, it took my players name.

ok, i see the problem… i have another script making an instance intvalue, cause i needed that value there to stop players from buying more than one stall/lot. an ideas to work around the intvalue? this script is a gobal stockmarket script. checks each players stall to see if each player is selling the same thing and with an equation i have, uses that to drive the prices.

Run this in Play Solo in studio and look at the Lots folder once running. Check that it only contains your lot models and that nothing else has been put into the folder upon runtime.

To help diagnose the issue, you could add a line

print( v, v:FindFirstChild('Type') )

Just after the for line.

This will show you if v is indeed a Lot and if Type exists inside it.

Check if v is a Model, not the StringValue

for i,v in pairs (lottab) do
    if v:IsA("Model") then
        if v.Type.Value == 1 then 
    	     table.insert(appltab,1,1)
        end
        if v.Type.Value == 2 then
 		table.insert(breatab,1,1)
    	end
    	if v.Type.Value == 3 then
    		table.insert(breatab,1,1)
    	end
    end
end

Thank you so much. I didnt even know about IsA. So IsA check the classname?

Yup.
You can use either Instance:IsA(“Class”) or Instance.ClassName == “Class”

1 Like