How to get index in table.find

Hello!

I want to know how to get the index in table.find. I want to make a script where if a player leaves and is in the table, it’ll remove that certain player. I don’t know how to do it, and I can’t find anything relating to my issue on the fourms.

table.find returns the index, and table.remove takes the index–they’re perfect for each other!

local tab = {'player'}
local index = table.find(tab, 'player')

if index then
    table.remove(tab, index)
end
3 Likes