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.

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

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