Hello, I’m currently working on a waypoint percentage program where each part is assigned a percentage. I loop through each waypoint part inside a folder, and create a table for it. However, I’m not sure how to do this through code…
for _, waypoint in pairs(workspace.Cafeteria.Waypoints:GetChildren()) do
--Create a smaller table inside the main table for each part
end
--Add that to this table as shown below
local waypointPercentages = {
{Value1 = 100},
{Value2 = 100},
}
Any help would be appreciated!
As I understand what you are trying to do, use table.insert:
local waypointPercentages = {}
for _, waypoint in pairs(workspace.Cafeteria.Waypoints:GetChildren()) do
table.insert(waypointPercentages, { Value = "value" })
end
Please correct me if this is not what you are trying to achieve
1 Like
This is correct, however when:
for pos, val in next, waypointPercentages do
print(val[2])
end
it prints nil
(same with val[1])
Each table you added to the main table only has a single key of Value. You cannot pull a value from them with an index of 1 or 2.