Table issues, overshadowing variable

  1. What I you want to achieve? I’m working on a tower of hell game I’m just making a rough outline set. I want to get a random Item from the folder add it to my table and spawn it in

  2. What is the issue?

    image

-- Thanks in advance

table is already a library, maybe rename the children table to something else so it doesn’t get overriden.

1 Like

I’ll try that.Thanks a lot. :slight_smile:

It didn’t work

Could you show the script with the line number?

1 Like

If you are looking to get 1 item, consider using this

local item
do
    local children = something:GetChildren()
    item = children[math.random(1,#children)]
end

What you did wrong here is that

local math = 1+ 1+ 1+1+ 1+1
math = math.sin(math) --> error, you redefined math!
4 Likes

You are overshadowing the library. This means that the original table global was overwritten and is now a simple variable in that scope. Do not use this practice and use alternate variable names which are more descriptive.

1 Like