I'm writing a script that is supposed to find the number of objects in a model with a certain name and return the number to me. I have attempted this but I keep getting the error - "attempt to index upvalue 'PACK' (a nil value)" How can I fix this?
local player = game.Players.LocalPlayer
local PACK = player:findFirstChild("Pack")
local BUTTON = script.Parent
local FRAME = BUTTON.Parent.Parent.Parent.ShowFrame1
local NBox1 = FRAME.ColumnFrame2.BoxFrame2
local NBox2 = FRAME.ColumnFrame2.BoxFrame3
local NBox3 = FRAME.ColumnFrame2.BoxFrame4
local NBox4 = FRAME.ColumnFrame2.BoxFrame5
local HBox1 = FRAME.ColumnFrame3.BoxFrame2
local HBox2 = FRAME.ColumnFrame3.BoxFrame3
local HBox3 = FRAME.ColumnFrame3.BoxFrame4
local HBox4 = FRAME.ColumnFrame3.BoxFrame5
function check_Have()
local PACKTAB = PACK:GetChildren()
local name = FRAME.RowFrame2.TextLabel.Text
local obj = PACK:GetChildren()
local count = #obj
for index, child in pairs(PACKTAB) do
if child.Name == name then
local count = #name
end
print(count)
end
end
--function get_Have()
--end
function onMouseButton1Down(mouse)
FRAME.Visible = (not FRAME.Visible)
check_Have()
end
BUTTON.MouseButton1Down:connect(onMouseButton1Down)

1 comment
perfect! thank you!