Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do i get the quantity of a specific item in something such as a parent/folder?

been trying to figure it out for a while, i know what im trying to do but i just dont know how to get it. its a crafting script where it figures out the price of the item and then will craft it.

please help if you can :)

script.Parent.MouseButton1Click:Connect(function(player)
for _, kids in pairs(script.Parent.Parent.recipe:GetChildren()) do
if kids.ClassName == ("IntValue") then
local item = kids.Name
local price = kids.Value 

-- heres where im lost 
local items = game.Players.LocalPlayer.PlayerGui.ScreenGui.inv.ImageLabel.Frame:GetChildren() 
	local num = #items
	print (num)
	if num >= price then
--haven't finished this part yet

game.ReplicatedStorage.crafting.sendoff:FireServer(item, price)	
   end
  end
end
end)

1 answer

✓ Accepted answer

(Edited the answer) So you want to remove e.g the woods from the table? example:

local stuff = workspace.Folder:GetChildren()
for i,v in pairs (stuff) do
	if v.Name ~= "wood" then -- if object's name is not wood
		table.remove(stuff, i) --Removing object from table
	end
end

You have to detect if there is an object called wood in a table, and if yes, then remove it.

1 comment

0

no ive already worked out the number, im trying to figure out how to get a specific item as there are 2 other things inside (sorry for not specifying) that isnt wood

This discussion is preserved as it was. New answers, comments, and votes are closed.