Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
Miniller 562 Moderation Voter
5 years ago
Edited 5 years ago

(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.

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 StormcloakGuard 30 — 5y
Ad

Answer this question