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

Why can't I remove a specific value from a table?

Asked by 3 years ago

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.

01local PlrSave = nil
02 
03script.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)
09 
10        for i, v in pairs(caroccupants) do
11            print(i)
12            print(v)
13 
14        end
15    else
View all 28 lines...

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

Answer this question