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

Why is this error called?

local unions = {}

function DefineForUnion() -- 
	local things = game.Workspace:GetChildren()
	for thing in #things do
		if thing.className == "UnionOperation" then
			table.insert(thing)
		end
	end
end

It gives the error: "attempted to call a number value".

Any suggestions?

1 answer

✓ Accepted answer

You have a couple thing wrong.

table.insert takes 2 arguments, the table and thing you want to insert.

example:

local Table = {}

table.insert(Table,"Hello")

The for loop you were using is not the best for tables, use a in pairs loop instead.

Here is a fixed version of your code:

local unions = {}

function DefineForUnion() -- 
local things = game.Workspace:GetChildren()
 	for i , v in pairs (things) do
		if v.className == "UnionOperation" then
			table.insert(unions,v)
		end
	end
end

1 comment

0

Thanks, Man!

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