Why can't I remove a specific value from a table?
My script Isn't removing a player from a table when they get out of a seat. This script is intended to be a script where if a player sits in a seat they get added to a table and if they get up then they get removed.
03 | script.Parent.Seat:GetPropertyChangedSignal( "Occupant" ):Connect( function () |
04 | if script.Parent.Seat.Occupant ~ = nil then |
05 | local Char = script.Parent.Seat.Occupant.Parent |
06 | local player = players:GetPlayerFromCharacter(Char) |
07 | local PlrSave = player |
08 | table.insert(caroccupants, player) |
10 | for i, v in pairs (caroccupants) do |
16 | if PlrSave and PlrSave:IsA( "Player" ) then |
17 | for i, v in pairs (caroccupants) do |
19 | table.remove(caroccupants, i) |
22 | for i, v in pairs (caroccupants) do |
Here is the output
16:32:03.661 1 - Server - Script:36
16:32:03.661 hohoyoyo291 - Server - Script:37
-- when I sat in it the first time, also it is not printing anything here, maybe it is the
16:32:07.411 1 - Server - Script:36
16:32:07.411 hohoyoyo291 - Server - Script:37
16:32:07.411 2 - Server - Script:36 -- there should only be 1
16:32:07.412 hohoyoyo291 - Server - Script:37 -- it didn't remove this value