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

Can you get all the players in a server script table?

I'm making a murder mystery game and getting everyone that's not the murder of sheriff will be an innocent but I wanna get everyone from the table that's the innocent but I tried some scripts and it didn't work, Can anyone help me?

Here's the code thats the problem:

local innocent = playersAlive:GetChildren()

2 comments

0

You only need to post the code you are having an issue with, could you cut this down to just the problem area?

0

ok

2 answers

I would recommend using "i,v in pairs"

for i, v in pairs(innocent)do
	--whatever you need to do
end

This will loop through the table and do what is inside the for loop for every member of the table. For instance this will print the name of every innocent player:

for i, v in pairs(innocent)do
	print(v.Name) -- v refers to the member of the table (i refers to the index or what loop you are currently on.)
end

I'm not very good with words, but I hope this helped. ;)

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