Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

removing a player from a table when they leave, problems? (edited)

Asked by 6 years ago
Edited 6 years ago

I have done this before, but i cannot figure out why it isn't working. the game im putting it in is FE, so that may be why. or i might be doing it differently from before, since it's been a while since i have done this,

the script doesnt remove player's UserId's from the table when they leave and it just keep them there,

it's a global player list, so i cant just get from players in the servers.

function playerAdded(player)            
    online:UpdateAsync("onlinep", function(old)
            onlineplayers = old or {}           
        table.insert(onlineplayers, player.Name)    
        return onlineplayers    
    end)
end

function playerLeft(playerl)
    for i,v in pairs(onlineplayers) do  
        if v == playerl.Name then   
        table.remove(onlineplayers, i)
        return onlineplayers
        end
    end
end

game.Players.PlayerAdded:Connect(playerAdded)
game.Players.PlayerRemoving:Connect(playerLeft)

it's been a while since i have done this and i can't find anything that works on the wiki, but it never worked.

0
I would imagine that the problem lies with when you add their ID in, not when you remove it. Could we see that code? lukeb50 631 — 6y
0
it works because i get the player's name from the ID to put on the gui. but okay RobloxianDestory 262 — 6y
0
i just changed it to player's names though because it's not saving data RobloxianDestory 262 — 6y

Answer this question