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

Why's my table not being read properly by the script?

Asked by
niroqeo 123
3 years ago
Edited 3 years ago

Hi!

So I've been scripting an animation thing, and a for loop picks up all the animations in a folder and inserts it into a table. It works, until when I try to read the table, and it just returns nil.

01local animInstances = {
02        idleInstance = nil,
03        mouseSlashInstance1 = nil,
04        mouseSlashInstance2 = nil,
05        mouseSlashInstance3 = nil,
06        mouseSlashInstance4 = nil,
07        mouseSlashInstance5 = nil,
08    }
09    local count = 0
10    for i, instance in ipairs(animations:GetChildren()) do
11        count = count + 1
12        local gsub = animations[string.gsub(instance.Name, "Instance", "")]
13        animInstances[count] = animations[gsub.Name]
14    end
15 
16    for i,v in pairs(animInstances) do
17        print(v) -- this doesn't return nil, and prints correctly
18    end
19 
20    local idleAnim = animator:LoadAnimation(animInstances.idleInstance) -- this errors

any ideas?

1 answer

Log in to vote
1
Answered by
niroqeo 123
3 years ago

fixed it, turns out that when i was using "count" it was creating a new variable in the table

0
Then delete this post Krektonix_Youtube 85 — 3y
0
You fixed your own problem so it's answered Xapelize 2658 — 3y
Ad

Answer this question