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

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

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.

local animInstances = {
        idleInstance = nil,
        mouseSlashInstance1 = nil,
        mouseSlashInstance2 = nil,
        mouseSlashInstance3 = nil,
        mouseSlashInstance4 = nil,
        mouseSlashInstance5 = nil,
    }
    local count = 0
    for i, instance in ipairs(animations:GetChildren()) do
        count = count + 1
        local gsub = animations[string.gsub(instance.Name, "Instance", "")]
        animInstances[count] = animations[gsub.Name]
    end
    
    for i,v in pairs(animInstances) do
        print(v) -- this doesn't return nil, and prints correctly
    end
    
    local idleAnim = animator:LoadAnimation(animInstances.idleInstance) -- this errors

any ideas?

1 answer

✓ Accepted answer

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

2 comments

0

Then delete this post

0

You fixed your own problem so it's answered

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