I have tried this
spawn(function() while wait() do local r3 = Region3.new(car.Platform.Position-Vector3.new(7,0,7),car.Platform.Position+Vector3.new(7,8,7)) for i, p in pairs(workspace:FindPartsInRegion3(r3,script.Parent,math.huge)) do local pl = game.Players:GetPlayerFromCharacter(p.Parent) if (pl ~= nil) then table.insert(plist,pl) else table.remove(plist, #plist) end end end end)
But it doesn't seem to work. How can i fix this?
table.remove takes instance number value placement in a table, and not instance direcxtly.
spawn(function() while wait() do local r3 = Region3.new(car.Platform.Position-Vector3.new(7,0,7),car.Platform.Position+Vector3.new(7,8,7)) for i, p in pairs(workspace:FindPartsInRegion3(r3,script.Parent,math.huge)) do local pl = game.Players:GetPlayerFromCharacter(p.Parent) if (pl ~= nil) then table.insert(plist,pl) else table.remove(plist, i) end end end end)