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

Need help completing my system? Tables?

I want to insert a player in to the table then see if a player inside of a table said something, BUT FOR NOW, i want to add the players to the table and remove them when they leave, could you give me tips on this?

local tab = {}

game.Players.PlayerAdded:Connect(function(plr)
	table.insert(tab,plr)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	table.remove(tab,plr)
end)

This doesn't work, could you tell me why?

1 comment

0

If you post the error and/or table after a player joins i might be able to tell you.

1 answer

Use table.insert(tab, #tab, plr), this should fix it. If you post the error, I can tell you. For the chatting part, plr.Chatted:Connect() should work.

2 comments

0

Could you tell me why you're doing (tab, #tab, plr) ?

0

@malachiRashee the #tab is the length of the table, when using table.insert the arguments are (table, position, value).

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