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

Can you put instances in a table?

I'm making a shark bite game but instead of the shark being played by a human its gonna be played by a robot and I'm adding them to a table so that I can detect when they all die so the round can end, but when I tried putting them in a table it didn't really work, So can anyone help me?

local sharks = {}

for i, shark  in pairs(workspace:WaitForChild("Sharks"):GetChildren()) do
	if shark then
		table.insert(sharks, shark)
	end
end

4 comments

0

Why don't u uuh try it

0

I did

0

is the sharks folder empty?

0

Yeah

1 answer

local sharks = {}

for i, shark  in pairs(workspace:WaitForChild("Sharks"):GetChildren()) do
    if shark then
        table.insert(sharks, shark)
    end
end

You can add instances into a table your code is right but

I think the folder might have no shark so

when it saids

if shark then

It might not have a shark in that folder

so nothing might be added but other than that your code is fine

I think the problem is at the "if shark then"

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